File size: 1,026 Bytes
147e3ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
```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