ariG23498 HF Staff commited on
Commit
dbda1bb
·
verified ·
1 Parent(s): c153cc2

Upload HuggingFaceTB_SmolLM3-3B_3.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. HuggingFaceTB_SmolLM3-3B_3.py +33 -0
HuggingFaceTB_SmolLM3-3B_3.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "transformers",
5
+ # "torch",
6
+ # ]
7
+ # ///
8
+
9
+ try:
10
+ from transformers import AutoModelForCausalLM, AutoTokenizer
11
+
12
+ model_name = "HuggingFaceTB/SmolLM3-3B"
13
+ device = "cuda" # for GPU usage or "cpu" for CPU usage
14
+
15
+ # load the tokenizer and the model
16
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
17
+ model = AutoModelForCausalLM.from_pretrained(
18
+ model_name,
19
+ ).to(device)
20
+ with open('HuggingFaceTB_SmolLM3-3B_3.txt', 'w') as f:
21
+ f.write('Everything was good in HuggingFaceTB_SmolLM3-3B_3.txt')
22
+ except Exception as e:
23
+ with open('HuggingFaceTB_SmolLM3-3B_3.txt', 'w') as f:
24
+ import traceback
25
+ traceback.print_exc(file=f)
26
+ finally:
27
+ from huggingface_hub import upload_file
28
+ upload_file(
29
+ path_or_fileobj='HuggingFaceTB_SmolLM3-3B_3.txt',
30
+ repo_id='model-metadata/custom_code_execution_files',
31
+ path_in_repo='HuggingFaceTB_SmolLM3-3B_3.txt',
32
+ repo_type='dataset',
33
+ )