ariG23498 HF Staff commited on
Commit
6fba137
·
verified ·
1 Parent(s): 144cbb3

Upload HuggingFaceTB_SmolLM3-3B_3.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. HuggingFaceTB_SmolLM3-3B_3.py +63 -0
HuggingFaceTB_SmolLM3-3B_3.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "torch",
5
+ # "torchvision",
6
+ # "transformers",
7
+ # "diffusers",
8
+ # "sentence-transformers",
9
+ # "accelerate",
10
+ # "peft",
11
+ # "slack-sdk",
12
+ # ]
13
+ # ///
14
+
15
+ try:
16
+ from transformers import AutoModelForCausalLM, AutoTokenizer
17
+
18
+ model_name = "HuggingFaceTB/SmolLM3-3B"
19
+ device = "cuda" # for GPU usage or "cpu" for CPU usage
20
+
21
+ # load the tokenizer and the model
22
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
23
+ model = AutoModelForCausalLM.from_pretrained(
24
+ model_name,
25
+ ).to(device)
26
+ with open('HuggingFaceTB_SmolLM3-3B_3.txt', 'w', encoding='utf-8') as f:
27
+ f.write('Everything was good in HuggingFaceTB_SmolLM3-3B_3.txt')
28
+ except Exception as e:
29
+ import os
30
+ from slack_sdk import WebClient
31
+ client = WebClient(token=os.environ['SLACK_TOKEN'])
32
+ client.chat_postMessage(
33
+ channel='#hub-model-metadata-snippets-sprint',
34
+ text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/HuggingFaceTB_SmolLM3-3B_3.txt|HuggingFaceTB_SmolLM3-3B_3.txt>',
35
+ )
36
+
37
+ with open('HuggingFaceTB_SmolLM3-3B_3.txt', 'a', encoding='utf-8') as f:
38
+ import traceback
39
+ f.write('''```CODE:
40
+ from transformers import AutoModelForCausalLM, AutoTokenizer
41
+
42
+ model_name = "HuggingFaceTB/SmolLM3-3B"
43
+ device = "cuda" # for GPU usage or "cpu" for CPU usage
44
+
45
+ # load the tokenizer and the model
46
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
47
+ model = AutoModelForCausalLM.from_pretrained(
48
+ model_name,
49
+ ).to(device)
50
+ ```
51
+
52
+ ERROR:
53
+ ''')
54
+ traceback.print_exc(file=f)
55
+
56
+ finally:
57
+ from huggingface_hub import upload_file
58
+ upload_file(
59
+ path_or_fileobj='HuggingFaceTB_SmolLM3-3B_3.txt',
60
+ repo_id='model-metadata/code_execution_files',
61
+ path_in_repo='HuggingFaceTB_SmolLM3-3B_3.txt',
62
+ repo_type='dataset',
63
+ )