code_execution_files / google_embeddinggemma-300m_6.txt
ariG23498's picture
ariG23498 HF Staff
Upload google_embeddinggemma-300m_6.txt with huggingface_hub
147e3ed verified
raw
history blame
1.03 kB
```CODE:
labels = ["Billing Issue", "Technical Support", "Sales Inquiry"]
sentence = [
"Excuse me, the app freezes on the login screen. It won't work even when I try to reset my password.",
"I would like to inquire about your enterprise plan pricing and features for a team of 50 people.",
]
# Calculate embeddings by calling model.encode()
label_embeddings = model.encode(labels, prompt_name="Classification")
embeddings = model.encode(sentence, prompt_name="Classification")
# Calculate the embedding similarities
similarities = model.similarity(embeddings, label_embeddings)
print(similarities)
idx = similarities.argmax(1)
print(idx)
for example in sentence:
print("πŸ™‹β€β™‚οΈ", example, "-> πŸ€–", labels[idx[sentence.index(example)]])
```
ERROR:
Traceback (most recent call last):
File "/tmp/google_embeddinggemma-300m_69QHTnB.py", line 22, in <module>
label_embeddings = model.encode(labels, prompt_name="Classification")
^^^^^
NameError: name 'model' is not defined