ariG23498 HF Staff commited on
Commit
873d2c2
·
verified ·
1 Parent(s): e2a63c7

Upload cerebras_Kimi-Linear-REAP-35B-A3B-Instruct_0.py with huggingface_hub

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