Upload deepseek-ai_DeepSeek-R1-0528_1.py with huggingface_hub
Browse files
deepseek-ai_DeepSeek-R1-0528_1.py
CHANGED
@@ -12,6 +12,19 @@ try:
|
|
12 |
|
13 |
tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-R1-0528", trust_remote_code=True)
|
14 |
model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-R1-0528", trust_remote_code=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
with open('deepseek-ai_DeepSeek-R1-0528_1.txt', 'w') as f:
|
16 |
f.write('Everything was good in deepseek-ai_DeepSeek-R1-0528_1.txt')
|
17 |
except Exception as e:
|
|
|
12 |
|
13 |
tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-R1-0528", trust_remote_code=True)
|
14 |
model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-R1-0528", trust_remote_code=True)
|
15 |
+
messages = [
|
16 |
+
{"role": "user", "content": "Who are you?"},
|
17 |
+
]
|
18 |
+
inputs = ${processorVarName}.apply_chat_template(
|
19 |
+
messages,
|
20 |
+
add_generation_prompt=True,
|
21 |
+
tokenize=True,
|
22 |
+
return_dict=True,
|
23 |
+
return_tensors="pt",
|
24 |
+
).to(model.device)
|
25 |
+
|
26 |
+
outputs = model.generate(**inputs, max_new_tokens=40)
|
27 |
+
print(${processorVarName}.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
|
28 |
with open('deepseek-ai_DeepSeek-R1-0528_1.txt', 'w') as f:
|
29 |
f.write('Everything was good in deepseek-ai_DeepSeek-R1-0528_1.txt')
|
30 |
except Exception as e:
|