Upload google_embeddinggemma-300m_7.txt with huggingface_hub
Browse files
google_embeddinggemma-300m_7.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
```CODE:
|
| 2 |
+
def check_word_similarities():
|
| 3 |
+
# Calculate the embedding similarities
|
| 4 |
+
print("similarity function: ", model.similarity_fn_name)
|
| 5 |
+
similarities = model.similarity(embeddings[0], embeddings[1:])
|
| 6 |
+
print(similarities)
|
| 7 |
+
|
| 8 |
+
for idx, word in enumerate(words[1:]):
|
| 9 |
+
print("🙋♂️ apple vs.", word, "-> 🤖 score: ", similarities.numpy()[0][idx])
|
| 10 |
+
|
| 11 |
+
# Calculate embeddings by calling model.encode()
|
| 12 |
+
embeddings = model.encode(words, prompt_name="STS")
|
| 13 |
+
|
| 14 |
+
check_word_similarities()
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
ERROR:
|
| 18 |
+
Traceback (most recent call last):
|
| 19 |
+
File "/tmp/google_embeddinggemma-300m_785mJ1M.py", line 24, in <module>
|
| 20 |
+
embeddings = model.encode(words, prompt_name="STS")
|
| 21 |
+
^^^^^
|
| 22 |
+
NameError: name 'model' is not defined
|