gabrielchua commited on
Commit
1cfb45a
·
verified ·
1 Parent(s): 36c68c2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +24 -13
README.md CHANGED
@@ -30,17 +30,28 @@ It leverages OpenAI’s `text-embedding-3-large` with a multi-head classifier to
30
  ---
31
 
32
  # Usage
33
- 1. Install packages
34
- ```bash
35
- pip install -r requirements.txt
36
- ```
37
-
38
- 2. Set your OpenAI key
39
- ```bash
40
- export OPENAI_API_KEY=sk-...
41
- ```
42
-
43
- 3. Run inference on an array of texts
44
- ```bash
45
- python inference.py "['Text 1', 'Text 2']"
 
 
 
 
 
 
 
 
 
 
 
46
  ```
 
30
  ---
31
 
32
  # Usage
33
+
34
+ ```python
35
+ import os
36
+ import numpy as np
37
+ from transformers import AutoModel
38
+ from openai import OpenAI
39
+
40
+ # Load model directly from HF
41
+ model = AutoModel.from_pretrained(
42
+ "govtech/lionguard-2",
43
+ trust_remote_code=True
44
+ )
45
+
46
+ # Get OpenAI embeddings (users to input their own OpenAI API key)
47
+ client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
48
+ response = client.embeddings.create(
49
+ input="Hello, world!", # users to input their own text
50
+ model="text-embedding-3-large",
51
+ dimensions=1536 # dimensions of the embedding
52
+ )
53
+ embeddings = np.array([data.embedding for data in response.data])
54
+
55
+ # Run LionGuard 2
56
+ results = model.predict(embeddings)
57
  ```