Text Generation
Transformers
Safetensors
English
qwen2
reasoning
chain-of-thought
qwen
tiny
whirlwindai
conversational
text-generation-inference
Instructions to use WhirlwindAI/Qwen-R1-0.5B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use WhirlwindAI/Qwen-R1-0.5B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="WhirlwindAI/Qwen-R1-0.5B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("WhirlwindAI/Qwen-R1-0.5B") model = AutoModelForCausalLM.from_pretrained("WhirlwindAI/Qwen-R1-0.5B") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use WhirlwindAI/Qwen-R1-0.5B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "WhirlwindAI/Qwen-R1-0.5B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "WhirlwindAI/Qwen-R1-0.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/WhirlwindAI/Qwen-R1-0.5B
- SGLang
How to use WhirlwindAI/Qwen-R1-0.5B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "WhirlwindAI/Qwen-R1-0.5B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "WhirlwindAI/Qwen-R1-0.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "WhirlwindAI/Qwen-R1-0.5B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "WhirlwindAI/Qwen-R1-0.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use WhirlwindAI/Qwen-R1-0.5B with Docker Model Runner:
docker model run hf.co/WhirlwindAI/Qwen-R1-0.5B
metadata
license: apache-2.0
language:
- en
tags:
- reasoning
- chain-of-thought
- qwen
- tiny
- whirlwindai
pipeline_tag: text-generation
datasets:
- WhirlwindAI/Soft-CoT-1K
library_name: transformers
base_model:
- Qwen/Qwen2.5-0.5B-Instruct
π‘ The Idea
Good answers come from good thinking.
Qwen-R1-0.5B is a fine-tuned version of Qwen2.5-0.5B-Instruct trained to reason before it answers using explicit <thinking> tags.
Instead of jumping straight to the answer, this model generates its reasoning first β making it more transparent, more reliable, and easier to debug.
π§ How It Works
Every response is structured as:
User: {question}
Assistant: <thinking>{reasoning}</thinking>
{answer}
The model learns to:
- Think β generate step-by-step reasoning
- Answer β provide the final response
π Training Details
| Property | Value |
|---|---|
| Base Model | Qwen2.5-0.5B-Instruct |
| Dataset | WhirlwindAI/Soft-CoT-1K |
| Examples | 1,355 |
| Method | QLoRA (4-bit) |
| Epochs | 3 |
| Learning Rate | 2e-4 |
| LoRA Rank | 16 |
| LoRA Alpha | 32 |
π Quick Start
from transformers import AutoTokenizer, AutoModelForCausalLM
model_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.",
]
for q in questions:
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))
π Citation
@model{qwenr1_2026,
title={Qwen-R1-0.5B},
author={WhirlwindAI},
year={2026},
publisher={Hugging Face}
}