ariG23498 HF Staff commited on
Commit
f10a6ae
·
verified ·
1 Parent(s): 0f59b17

Upload DatologyAI_luxical-one_0.py with huggingface_hub

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