ariG23498 HF Staff commited on
Commit
6e67417
·
verified ·
1 Parent(s): 546c051

Upload Motif-Technologies_Motif-2-12.7B-Instruct_0.py with huggingface_hub

Browse files
Motif-Technologies_Motif-2-12.7B-Instruct_0.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "numpy",
5
+ # "einops",
6
+ # "pandas",
7
+ # "protobuf",
8
+ # "torch",
9
+ # "sentencepiece",
10
+ # "torchvision",
11
+ # "transformers",
12
+ # "timm",
13
+ # "diffusers",
14
+ # "sentence-transformers",
15
+ # "accelerate",
16
+ # "peft",
17
+ # "slack-sdk",
18
+ # ]
19
+ # ///
20
+
21
+ try:
22
+ # Use a pipeline as a high-level helper
23
+ from transformers import pipeline
24
+
25
+ pipe = pipeline("text-generation", model="Motif-Technologies/Motif-2-12.7B-Instruct", trust_remote_code=True)
26
+ messages = [
27
+ {"role": "user", "content": "Who are you?"},
28
+ ]
29
+ pipe(messages)
30
+ with open('Motif-Technologies_Motif-2-12.7B-Instruct_0.txt', 'w', encoding='utf-8') as f:
31
+ f.write('Everything was good in Motif-Technologies_Motif-2-12.7B-Instruct_0.txt')
32
+ except Exception as e:
33
+ import os
34
+ from slack_sdk import WebClient
35
+ client = WebClient(token=os.environ['SLACK_TOKEN'])
36
+ client.chat_postMessage(
37
+ channel='#hub-model-metadata-snippets-sprint',
38
+ text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/Motif-Technologies_Motif-2-12.7B-Instruct_0.txt|Motif-Technologies_Motif-2-12.7B-Instruct_0.txt>',
39
+ )
40
+
41
+ with open('Motif-Technologies_Motif-2-12.7B-Instruct_0.txt', 'a', encoding='utf-8') as f:
42
+ import traceback
43
+ f.write('''```CODE:
44
+ # Use a pipeline as a high-level helper
45
+ from transformers import pipeline
46
+
47
+ pipe = pipeline("text-generation", model="Motif-Technologies/Motif-2-12.7B-Instruct", trust_remote_code=True)
48
+ messages = [
49
+ {"role": "user", "content": "Who are you?"},
50
+ ]
51
+ pipe(messages)
52
+ ```
53
+
54
+ ERROR:
55
+ ''')
56
+ traceback.print_exc(file=f)
57
+
58
+ finally:
59
+ from huggingface_hub import upload_file
60
+ upload_file(
61
+ path_or_fileobj='Motif-Technologies_Motif-2-12.7B-Instruct_0.txt',
62
+ repo_id='model-metadata/code_execution_files',
63
+ path_in_repo='Motif-Technologies_Motif-2-12.7B-Instruct_0.txt',
64
+ repo_type='dataset',
65
+ )