ariG23498 HF Staff commited on
Commit
87e7afb
·
verified ·
1 Parent(s): f7558b0

Upload meta-llama_Llama-3.2-1B_2.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. meta-llama_Llama-3.2-1B_2.py +53 -0
meta-llama_Llama-3.2-1B_2.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # Load model directly
17
+ from transformers import AutoTokenizer, AutoModelForCausalLM
18
+
19
+ tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-1B")
20
+ model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-1B")
21
+ with open('meta-llama_Llama-3.2-1B_2.txt', 'w', encoding='utf-8') as f:
22
+ f.write('Everything was good in meta-llama_Llama-3.2-1B_2.txt')
23
+ except Exception as e:
24
+ import os
25
+ from slack_sdk import WebClient
26
+ client = WebClient(token=os.environ['SLACK_TOKEN'])
27
+ client.chat_postMessage(
28
+ channel='#exp-slack-alerts',
29
+ text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/meta-llama_Llama-3.2-1B_2.txt|meta-llama_Llama-3.2-1B_2.txt>',
30
+ )
31
+
32
+ with open('meta-llama_Llama-3.2-1B_2.txt', 'a', encoding='utf-8') as f:
33
+ import traceback
34
+ f.write('''```CODE:
35
+ # Load model directly
36
+ from transformers import AutoTokenizer, AutoModelForCausalLM
37
+
38
+ tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-1B")
39
+ model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-1B")
40
+ ```
41
+
42
+ ERROR:
43
+ ''')
44
+ traceback.print_exc(file=f)
45
+
46
+ finally:
47
+ from huggingface_hub import upload_file
48
+ upload_file(
49
+ path_or_fileobj='meta-llama_Llama-3.2-1B_2.txt',
50
+ repo_id='model-metadata/code_execution_files',
51
+ path_in_repo='meta-llama_Llama-3.2-1B_2.txt',
52
+ repo_type='dataset',
53
+ )