fromtransformersimportAutoTokenizer,AutoModelForCausalLMmodel_name="WhirlwindAI/Qwen-R1-0.5B"tokenizer=AutoTokenizer.from_pretrained(model_name,trust_remote_code=True)model=AutoModelForCausalLM.from_pretrained(model_name,trust_remote_code=True)prompt="User: What is 2+2?\nAssistant: <thinking>"inputs=tokenizer(prompt,return_tensors="pt")outputs=model.generate(**inputs,max_new_tokens=50,do_sample=True,temperature=0.7)print(tokenizer.decode(outputs[0],skip_special_tokens=True))
📋 Sample Output
User: What is the capital of France?
Assistant: <thinking>Paris is the capital of France.</thinking>
Paris
📈 Performance
The model was evaluated on 10 out-of-distribution questions:
Category
Performance
Format (thinking tags)
✅ Excellent
General Knowledge
✅ Good
Creative Reasoning
✅ Good
Math/Logic
⚠️ Needs improvement
Physics/Science
⚠️ Needs improvement
🔬 What It Learned
Strength
Weakness
✅ Consistent <thinking> format
❌ Sometimes hallucinates facts
✅ Generates reasoning before answering
❌ Struggles with multi-step math
✅ Retains general knowledge
❌ Physics reasoning needs more data
🧪 Test It Yourself
questions=["What is the capital of France?","Explain entropy like I'm 5.","Write a short poem about a robot.",]forqinquestions:prompt=f"User: {q}\nAssistant: <thinking>"inputs=tokenizer(prompt,return_tensors="pt").to(model.device)outputs=model.generate(**inputs,max_new_tokens=80)print(tokenizer.decode(outputs[0],skip_special_tokens=True))