ariG23498 HF Staff commited on
Commit
3fad017
·
verified ·
1 Parent(s): a918d0d

Upload Qwen_Qwen3-Embedding-0.6B_0.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. Qwen_Qwen3-Embedding-0.6B_0.py +69 -0
Qwen_Qwen3-Embedding-0.6B_0.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "torch",
5
+ # "torchvision",
6
+ # "transformers",
7
+ # "accelerate",
8
+ # "peft",
9
+ # "slack-sdk",
10
+ # ]
11
+ # ///
12
+
13
+ try:
14
+ from sentence_transformers import SentenceTransformer
15
+
16
+ model = SentenceTransformer("Qwen/Qwen3-Embedding-0.6B")
17
+
18
+ sentences = [
19
+ "The weather is lovely today.",
20
+ "It's so sunny outside!",
21
+ "He drove to the stadium."
22
+ ]
23
+ embeddings = model.encode(sentences)
24
+
25
+ similarities = model.similarity(embeddings, embeddings)
26
+ print(similarities.shape)
27
+ # [3, 3]
28
+ with open('Qwen_Qwen3-Embedding-0.6B_0.txt', 'w', encoding='utf-8') as f:
29
+ f.write('Everything was good in Qwen_Qwen3-Embedding-0.6B_0.txt')
30
+ except Exception as e:
31
+ import os
32
+ from slack_sdk import WebClient
33
+ client = WebClient(token=os.environ['SLACK_TOKEN'])
34
+ client.chat_postMessage(
35
+ channel='#exp-slack-alerts',
36
+ text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/Qwen_Qwen3-Embedding-0.6B_0.txt|Qwen_Qwen3-Embedding-0.6B_0.txt>',
37
+ )
38
+
39
+ with open('Qwen_Qwen3-Embedding-0.6B_0.txt', 'a', encoding='utf-8') as f:
40
+ import traceback
41
+ f.write('''```CODE:
42
+ from sentence_transformers import SentenceTransformer
43
+
44
+ model = SentenceTransformer("Qwen/Qwen3-Embedding-0.6B")
45
+
46
+ sentences = [
47
+ "The weather is lovely today.",
48
+ "It's so sunny outside!",
49
+ "He drove to the stadium."
50
+ ]
51
+ embeddings = model.encode(sentences)
52
+
53
+ similarities = model.similarity(embeddings, embeddings)
54
+ print(similarities.shape)
55
+ # [3, 3]
56
+ ```
57
+
58
+ ERROR:
59
+ ''')
60
+ traceback.print_exc(file=f)
61
+
62
+ finally:
63
+ from huggingface_hub import upload_file
64
+ upload_file(
65
+ path_or_fileobj='Qwen_Qwen3-Embedding-0.6B_0.txt',
66
+ repo_id='model-metadata/code_execution_files',
67
+ path_in_repo='Qwen_Qwen3-Embedding-0.6B_0.txt',
68
+ repo_type='dataset',
69
+ )