Views
No views yet
<think> tags) prior to any reinforcement learning or distillation phases.Qwen/Qwen2.5-3BSFTTrainernohurry/Opus-4.6-Reasoning-3000x-filtered (A highly filtered dataset featuring intricate reasoning chains natively formatted in ChatML)transformers library. The model responds exceptionally well using the standard ChatML prompt format.1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
3
4model_id = "Phonsiri/Qwen2.5-3B-SFT-Reasoning"
5
6# Load the SFT model
7tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
8model = AutoModelForCausalLM.from_pretrained(
9 model_id,
10 device_map="auto",
11 torch_dtype=torch.bfloat16,
12 trust_remote_code=True
13)
14
15# ChatML Format
16messages = [
17 {"role": "system", "content": "You are Qwen, a brilliant and helpful reasoning assistant."},
18 {"role": "user", "content": "A father is 45 years old and his son is 15. In how many years will the father be exactly twice as old as his son?"}
19]
20
21text = tokenizer.apply_chat_template(
22 messages,
23 tokenize=False,
24 add_generation_prompt=True
25)
26
27model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
28
29# Provide real-time streaming to watch the reasoning process unfold
30streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=False)
31
32# Terminate cleanly on <|im_end|>
33terminators = [
34 tokenizer.eos_token_id,
35 tokenizer.convert_tokens_to_ids("<|im_end|>")
36]
37
38_ = model.generate(
39 **model_inputs,
40 streamer=streamer,
41 max_new_tokens=4096,
42 temperature=0.7,
43 top_p=0.9,
44 do_sample=True,
45 eos_token_id=terminators
46)