Upload google_embeddinggemma-300m_6.txt with huggingface_hub
Browse files
google_embeddinggemma-300m_6.txt
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
```CODE:
|
| 2 |
+
labels = ["Billing Issue", "Technical Support", "Sales Inquiry"]
|
| 3 |
+
|
| 4 |
+
sentence = [
|
| 5 |
+
"Excuse me, the app freezes on the login screen. It won't work even when I try to reset my password.",
|
| 6 |
+
"I would like to inquire about your enterprise plan pricing and features for a team of 50 people.",
|
| 7 |
+
]
|
| 8 |
+
|
| 9 |
+
# Calculate embeddings by calling model.encode()
|
| 10 |
+
label_embeddings = model.encode(labels, prompt_name="Classification")
|
| 11 |
+
embeddings = model.encode(sentence, prompt_name="Classification")
|
| 12 |
+
|
| 13 |
+
# Calculate the embedding similarities
|
| 14 |
+
similarities = model.similarity(embeddings, label_embeddings)
|
| 15 |
+
print(similarities)
|
| 16 |
+
|
| 17 |
+
idx = similarities.argmax(1)
|
| 18 |
+
print(idx)
|
| 19 |
+
|
| 20 |
+
for example in sentence:
|
| 21 |
+
print("🙋♂️", example, "-> 🤖", labels[idx[sentence.index(example)]])
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
ERROR:
|
| 25 |
+
Traceback (most recent call last):
|
| 26 |
+
File "/tmp/google_embeddinggemma-300m_69QHTnB.py", line 22, in <module>
|
| 27 |
+
label_embeddings = model.encode(labels, prompt_name="Classification")
|
| 28 |
+
^^^^^
|
| 29 |
+
NameError: name 'model' is not defined
|