Update README.md
Browse files
README.md
CHANGED
|
@@ -57,13 +57,16 @@ from google import genai
|
|
| 57 |
# Load model directly from HF
|
| 58 |
model = AutoModel.from_pretrained("govtech/lionguard-2.1", trust_remote_code=True)
|
| 59 |
|
|
|
|
|
|
|
|
|
|
| 60 |
# Get embeddings (users to input their own Gemini API key)
|
| 61 |
client = genai.Client(api_key=os.getenv("GEMINI_API_KEY"))
|
| 62 |
-
|
| 63 |
model="gemini-embedding-001",
|
| 64 |
contents=texts
|
| 65 |
)
|
| 66 |
-
embeddings = np.array([emb.values for emb in
|
| 67 |
|
| 68 |
# Run inference
|
| 69 |
results = model.predict(embeddings)
|
|
|
|
| 57 |
# Load model directly from HF
|
| 58 |
model = AutoModel.from_pretrained("govtech/lionguard-2.1", trust_remote_code=True)
|
| 59 |
|
| 60 |
+
# Text to classify
|
| 61 |
+
texts = ["hello", "world"]
|
| 62 |
+
|
| 63 |
# Get embeddings (users to input their own Gemini API key)
|
| 64 |
client = genai.Client(api_key=os.getenv("GEMINI_API_KEY"))
|
| 65 |
+
response = client.models.embed_content(
|
| 66 |
model="gemini-embedding-001",
|
| 67 |
contents=texts
|
| 68 |
)
|
| 69 |
+
embeddings = np.array([emb.values for emb in response.embeddings])
|
| 70 |
|
| 71 |
# Run inference
|
| 72 |
results = model.predict(embeddings)
|