Upload google_embeddinggemma-300m_5.py with huggingface_hub
Browse files- google_embeddinggemma-300m_5.py +28 -10
google_embeddinggemma-300m_5.py
CHANGED
|
@@ -11,15 +11,24 @@
|
|
| 11 |
# ///
|
| 12 |
|
| 13 |
try:
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
for sentence in [sentence_high, sentence_medium, sentence_low]:
|
| 20 |
print("πββοΈ")
|
| 21 |
print(sentence)
|
| 22 |
-
embeddings = model.encode(sentence
|
| 23 |
similarities = model.similarity(embeddings[0], embeddings[1])
|
| 24 |
print("`-> π€ score: ", similarities.numpy()[0][0])
|
| 25 |
with open('google_embeddinggemma-300m_5.txt', 'w', encoding='utf-8') as f:
|
|
@@ -36,15 +45,24 @@ except Exception as e:
|
|
| 36 |
with open('google_embeddinggemma-300m_5.txt', 'a', encoding='utf-8') as f:
|
| 37 |
import traceback
|
| 38 |
f.write('''```CODE:
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
for sentence in [sentence_high, sentence_medium, sentence_low]:
|
| 45 |
print("πββοΈ")
|
| 46 |
print(sentence)
|
| 47 |
-
embeddings = model.encode(sentence
|
| 48 |
similarities = model.similarity(embeddings[0], embeddings[1])
|
| 49 |
print("`-> π€ score: ", similarities.numpy()[0][0])
|
| 50 |
```
|
|
|
|
| 11 |
# ///
|
| 12 |
|
| 13 |
try:
|
| 14 |
+
# The sentences to encode
|
| 15 |
+
sentence_high = [
|
| 16 |
+
"The chef prepared a delicious meal for the guests.",
|
| 17 |
+
"A tasty dinner was cooked by the chef for the visitors."
|
| 18 |
+
]
|
| 19 |
+
sentence_medium = [
|
| 20 |
+
"She is an expert in machine learning.",
|
| 21 |
+
"He has a deep interest in artificial intelligence."
|
| 22 |
+
]
|
| 23 |
+
sentence_low = [
|
| 24 |
+
"The weather in Tokyo is sunny today.",
|
| 25 |
+
"I need to buy groceries for the week."
|
| 26 |
+
]
|
| 27 |
|
| 28 |
for sentence in [sentence_high, sentence_medium, sentence_low]:
|
| 29 |
print("πββοΈ")
|
| 30 |
print(sentence)
|
| 31 |
+
embeddings = model.encode(sentence)
|
| 32 |
similarities = model.similarity(embeddings[0], embeddings[1])
|
| 33 |
print("`-> π€ score: ", similarities.numpy()[0][0])
|
| 34 |
with open('google_embeddinggemma-300m_5.txt', 'w', encoding='utf-8') as f:
|
|
|
|
| 45 |
with open('google_embeddinggemma-300m_5.txt', 'a', encoding='utf-8') as f:
|
| 46 |
import traceback
|
| 47 |
f.write('''```CODE:
|
| 48 |
+
# The sentences to encode
|
| 49 |
+
sentence_high = [
|
| 50 |
+
"The chef prepared a delicious meal for the guests.",
|
| 51 |
+
"A tasty dinner was cooked by the chef for the visitors."
|
| 52 |
+
]
|
| 53 |
+
sentence_medium = [
|
| 54 |
+
"She is an expert in machine learning.",
|
| 55 |
+
"He has a deep interest in artificial intelligence."
|
| 56 |
+
]
|
| 57 |
+
sentence_low = [
|
| 58 |
+
"The weather in Tokyo is sunny today.",
|
| 59 |
+
"I need to buy groceries for the week."
|
| 60 |
+
]
|
| 61 |
|
| 62 |
for sentence in [sentence_high, sentence_medium, sentence_low]:
|
| 63 |
print("πββοΈ")
|
| 64 |
print(sentence)
|
| 65 |
+
embeddings = model.encode(sentence)
|
| 66 |
similarities = model.similarity(embeddings[0], embeddings[1])
|
| 67 |
print("`-> π€ score: ", similarities.numpy()[0][0])
|
| 68 |
```
|