Views
No views yet
1from unsloth import FastLanguageModel
2
3# 모델 로드
4model, tokenizer = FastLanguageModel.from_pretrained(
5 model_name="byh711/Qwen2.5-3B-MATH-GRPO-KOR",
6 max_seq_length=1024,
7 load_in_4bit=True,
8)
9
10# 추론 모드
11FastLanguageModel.for_inference(model)
12
13# 프롬프트 설정
14system_prompt = '''다음 형식으로 정확히 답변해주세요:
15<reasoning>
16단계별 풀이 과정을 자세히 설명
17</reasoning>
18<answer>
19최종 답안
20</answer>'''
21
22# 수학 문제 입력
23question = "어떤 수의 8배가 120보다 작을 때, 그 수의 최대 정수를 구하세요."
24
25messages = [
26 {"role": "system", "content": system_prompt},
27 {"role": "user", "content": question}
28]
29
30# 토큰화 및 생성
31inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt")
32outputs = model.generate(input_ids=inputs, max_new_tokens=200, temperature=0.1)
33response = tokenizer.decode(outputs[0], skip_special_tokens=True)
34print(response)<reasoning>
1. 주어진 조건: 어떤 수를 x라고 하면, 8x < 120
2. 부등식 풀이: x < 120/8 = 15
3. x는 15보다 작아야 하므로, 최대 정수는 14
</reasoning>
<answer>
14
</answer>