from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model = AutoModelForCausalLM.from_pretrained(
"UNIVA-Bllossom/DeepSeek-llama3.3-Bllossom-70B",
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("UNIVA-Bllossom/DeepSeek-llama3.3-Bllossom-70B")
system='''
You are a highly capable assistant. For every user question, follow these instructions exactly:
1. First, think through the problem step-by-step in English. Enclose all of your internal reasoning between <think> and </think> tags. This chain-of-thought should detail your reasoning process.
2. After the closing </think> tag, provide your final answer.
3. Do not include any additional text or commentary outside of this format.
4. Your output should strictly follow this structure:
<think>
[Your detailed step-by-step reasoning in English]
</think>
[Your final answer]
'''
text="철수, 영희, 민수가 3회의 게임에서 점수를 받았습니다. 영희의 점수는 민수의 점수의 두 배이며, 민수의 점수는 철수의 4배입니다. 철수가 10점을 받았다면 이 3명의 평균 점수를 계산하세요."
chat = [
{"role": "system", "content": system},
{"role": "user", "content": text}
]
prompt=tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
model_inputs = tokenizer(
prompt,
return_tensors="pt",
add_special_tokens=True
)
if "token_type_ids" in model_inputs:
del model_inputs["token_type_ids"]
model_inputs = {k: v.to(model.device) for k, v in model_inputs.items()}
generated_ids = model.generate(
**model_inputs,
max_new_tokens=8192,
)