ariG23498 HF Staff commited on
Commit
d7cba7e
·
verified ·
1 Parent(s): 8b36dbe

Upload google_embeddinggemma-300m_9.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. google_embeddinggemma-300m_9.py +4 -2
google_embeddinggemma-300m_9.py CHANGED
@@ -11,7 +11,8 @@
11
  # ///
12
 
13
  try:
14
- embeddings = model.encode(words, truncate_dim=512, normalize_embeddings=True)
 
15
 
16
  for idx, embedding in enumerate(embeddings):
17
  print(f"Embedding {idx+1}: {embedding.shape}")
@@ -32,7 +33,8 @@ except Exception as e:
32
  with open('google_embeddinggemma-300m_9.txt', 'a', encoding='utf-8') as f:
33
  import traceback
34
  f.write('''```CODE:
35
- embeddings = model.encode(words, truncate_dim=512, normalize_embeddings=True)
 
36
 
37
  for idx, embedding in enumerate(embeddings):
38
  print(f"Embedding {idx+1}: {embedding.shape}")
 
11
  # ///
12
 
13
  try:
14
+ model = SentenceTransformer(model_id, truncate_dim=256, similarity_fn_name="dot").to(device=device)
15
+ embeddings = model.encode(words, prompt_name="STS", normalize_embeddings=True)
16
 
17
  for idx, embedding in enumerate(embeddings):
18
  print(f"Embedding {idx+1}: {embedding.shape}")
 
33
  with open('google_embeddinggemma-300m_9.txt', 'a', encoding='utf-8') as f:
34
  import traceback
35
  f.write('''```CODE:
36
+ model = SentenceTransformer(model_id, truncate_dim=256, similarity_fn_name="dot").to(device=device)
37
+ embeddings = model.encode(words, prompt_name="STS", normalize_embeddings=True)
38
 
39
  for idx, embedding in enumerate(embeddings):
40
  print(f"Embedding {idx+1}: {embedding.shape}")