ariG23498 HF Staff commited on
Commit
ef48532
·
verified ·
1 Parent(s): 9ea7af8

Upload google_embeddinggemma-300m_2.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. google_embeddinggemma-300m_2.py +34 -9
google_embeddinggemma-300m_2.py CHANGED
@@ -34,17 +34,42 @@ try:
34
  with open('google_embeddinggemma-300m_2.txt', 'w', encoding='utf-8') as f:
35
  f.write('Everything was good in google_embeddinggemma-300m_2.txt')
36
  except Exception as e:
37
- with open('google_embeddinggemma-300m_2.txt', 'w', encoding='utf-8') as f:
 
 
 
 
 
 
 
 
38
  import traceback
39
- traceback.print_exc(file=f)
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
- import os
42
- from slack_sdk import WebClient
43
- client = WebClient(token=os.environ['SLACK_TOKEN'])
44
- client.chat_postMessage(
45
- channel='#exp-slack-alerts',
46
- text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/google_embeddinggemma-300m_2.txt|google_embeddinggemma-300m_2.txt>',
47
- )
 
 
 
 
48
  finally:
49
  from huggingface_hub import upload_file
50
  upload_file(
 
34
  with open('google_embeddinggemma-300m_2.txt', 'w', encoding='utf-8') as f:
35
  f.write('Everything was good in google_embeddinggemma-300m_2.txt')
36
  except Exception as e:
37
+ import os
38
+ from slack_sdk import WebClient
39
+ client = WebClient(token=os.environ['SLACK_TOKEN'])
40
+ client.chat_postMessage(
41
+ channel='#exp-slack-alerts',
42
+ text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/google_embeddinggemma-300m_2.txt|google_embeddinggemma-300m_2.txt>',
43
+ )
44
+
45
+ with open('google_embeddinggemma-300m_2.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
+ ```
69
+ ERROR:
70
+ ')
71
+ traceback.print_exc(file=f)
72
+
73
  finally:
74
  from huggingface_hub import upload_file
75
  upload_file(