ariG23498 HF Staff commited on
Commit
649ce9a
·
verified ·
1 Parent(s): 725366c

Upload HuggingFaceTB_SmolLM3-3B_0.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. HuggingFaceTB_SmolLM3-3B_0.py +32 -0
HuggingFaceTB_SmolLM3-3B_0.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "transformers",
5
+ # "torch",
6
+ # ]
7
+ # ///
8
+
9
+ try:
10
+ # Use a pipeline as a high-level helper
11
+ from transformers import pipeline
12
+ from transformers import AutoTokenizer
13
+
14
+ model_id = "HuggingFaceTB/SmolLM3-3B"
15
+
16
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
17
+
18
+ pipe = pipeline("text-generation", model=model_id, tokenizer=tokenizer)
19
+ with open('HuggingFaceTB_SmolLM3-3B_0.txt', 'w') as f:
20
+ f.write('Everything was good in HuggingFaceTB_SmolLM3-3B_0.txt')
21
+ except Exception as e:
22
+ with open('HuggingFaceTB_SmolLM3-3B_0.txt', 'w') as f:
23
+ import traceback
24
+ traceback.print_exc(file=f)
25
+ finally:
26
+ from huggingface_hub import upload_file
27
+ upload_file(
28
+ path_or_fileobj='HuggingFaceTB_SmolLM3-3B_0.txt',
29
+ repo_id='model-metadata/custom_code_execution_files',
30
+ path_in_repo='HuggingFaceTB_SmolLM3-3B_0.txt',
31
+ repo_type='dataset',
32
+ )