Views
No views yet
<think> tags) generated by a larger teacher model (Qwen/Qwen3.5-9B).Qwen/Qwen3.5-0.8B-BaseQwen/Qwen3.5-9B (Used for dataset generation)<think> ... </think> tags before answering.fp161from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model_id = "Phonsiri/Qwen3.5-0.8B-Base-Distillation-Qwen3.5-9B"
5subfolder = "step_100" # Use the desired checkpoint step
6
7tokenizer = AutoTokenizer.from_pretrained(model_id, subfolder=subfolder)
8model = AutoModelForCausalLM.from_pretrained(
9 model_id,
10 subfolder=subfolder,
11 torch_dtype=torch.float16,
12 device_map="auto"
13)
14
15# Example Prompt
16messages = [
17 {"role": "system", "content": "You are a helpful assistant."},
18 {"role": "user", "content": "What is the square root of 256? Please explain your thinking."}
19]
20
21text = tokenizer.apply_chat_template(
22 messages,
23 tokenize=False,
24 add_generation_prompt=True,
25 enable_thinking=True, # 💡 Command the model to use <think> reasoning
26)
27
28inputs = tokenizer(text, return_tensors="pt").to(model.device)
29outputs = model.generate(**inputs, max_new_tokens=512)
30
31print(tokenizer.decode(outputs[0], skip_special_tokens=True))