ariG23498 HF Staff commited on
Commit
8cb3199
·
verified ·
1 Parent(s): 45e378a

Upload openai_gpt-oss-120b_2.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. openai_gpt-oss-120b_2.py +4 -36
openai_gpt-oss-120b_2.py CHANGED
@@ -11,24 +11,8 @@
11
  # ///
12
 
13
  try:
14
- # Load model directly
15
- from transformers import AutoTokenizer, AutoModelForCausalLM
16
-
17
- tokenizer = AutoTokenizer.from_pretrained("openai/gpt-oss-120b")
18
- model = AutoModelForCausalLM.from_pretrained("openai/gpt-oss-120b")
19
- messages = [
20
- {"role": "user", "content": "Who are you?"},
21
- ]
22
- inputs = tokenizer.apply_chat_template(
23
- messages,
24
- add_generation_prompt=True,
25
- tokenize=True,
26
- return_dict=True,
27
- return_tensors="pt",
28
- ).to(model.device)
29
-
30
- outputs = model.generate(**inputs, max_new_tokens=40)
31
- print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
32
  with open('openai_gpt-oss-120b_2.txt', 'w', encoding='utf-8') as f:
33
  f.write('Everything was good in openai_gpt-oss-120b_2.txt')
34
  except Exception as e:
@@ -43,24 +27,8 @@ except Exception as e:
43
  with open('openai_gpt-oss-120b_2.txt', 'a', encoding='utf-8') as f:
44
  import traceback
45
  f.write('''```CODE:
46
- # Load model directly
47
- from transformers import AutoTokenizer, AutoModelForCausalLM
48
-
49
- tokenizer = AutoTokenizer.from_pretrained("openai/gpt-oss-120b")
50
- model = AutoModelForCausalLM.from_pretrained("openai/gpt-oss-120b")
51
- messages = [
52
- {"role": "user", "content": "Who are you?"},
53
- ]
54
- inputs = tokenizer.apply_chat_template(
55
- messages,
56
- add_generation_prompt=True,
57
- tokenize=True,
58
- return_dict=True,
59
- return_tensors="pt",
60
- ).to(model.device)
61
-
62
- outputs = model.generate(**inputs, max_new_tokens=40)
63
- print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
64
  ```
65
 
66
  ERROR:
 
11
  # ///
12
 
13
  try:
14
+ import os
15
+ os.environ['HF_TOKEN'] = 'YOUR_TOKEN_HERE'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  with open('openai_gpt-oss-120b_2.txt', 'w', encoding='utf-8') as f:
17
  f.write('Everything was good in openai_gpt-oss-120b_2.txt')
18
  except Exception as e:
 
27
  with open('openai_gpt-oss-120b_2.txt', 'a', encoding='utf-8') as f:
28
  import traceback
29
  f.write('''```CODE:
30
+ import os
31
+ os.environ['HF_TOKEN'] = 'YOUR_TOKEN_HERE'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  ```
33
 
34
  ERROR: