Instructions to use 96kevinli29/Qwen3-4B-R1-Distill with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use 96kevinli29/Qwen3-4B-R1-Distill with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="96kevinli29/Qwen3-4B-R1-Distill") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("96kevinli29/Qwen3-4B-R1-Distill") model = AutoModelForCausalLM.from_pretrained("96kevinli29/Qwen3-4B-R1-Distill", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use 96kevinli29/Qwen3-4B-R1-Distill with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "96kevinli29/Qwen3-4B-R1-Distill" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "96kevinli29/Qwen3-4B-R1-Distill", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/96kevinli29/Qwen3-4B-R1-Distill
- SGLang
How to use 96kevinli29/Qwen3-4B-R1-Distill 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 "96kevinli29/Qwen3-4B-R1-Distill" \ --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": "96kevinli29/Qwen3-4B-R1-Distill", "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 "96kevinli29/Qwen3-4B-R1-Distill" \ --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": "96kevinli29/Qwen3-4B-R1-Distill", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use 96kevinli29/Qwen3-4B-R1-Distill with Docker Model Runner:
docker model run hf.co/96kevinli29/Qwen3-4B-R1-Distill
Qwen3-4B-R1-Distill
A Qwen3-4B-Base model fine-tuned (full-parameter SFT) to solve math problems with long step-by-step reasoning.
The model thinks inside a <think> … </think> block and then writes a final answer with \boxed{}.
Training
- Data: 5,585 math problems with long reasoning traces from DeepSeek-R1 (OpenR1-Math-220k), filtered to verified-correct traces.
- Format: Qwen chat template; assistant turn =
<think>\n…\n</think>\n\n+ final solution. Prompt suffix:Please reason step by step, and put your final answer within \boxed{}. - Full fine-tuning, 5 epochs, batch size 32, learning rate 2e-5, sequence length up to 16k.
- End-of-sequence token set to
<|im_end|>.
Usage (vLLM)
from vllm import LLM, SamplingParams
llm = LLM("96kevinli29/Qwen3-4B-R1-Distill", max_model_len=20480)
q = "Find the remainder when 2^100 is divided by 7."
msgs = [{"role": "user", "content": q + "\n\nPlease reason step by step, and put your final answer within \\boxed{}."}]
sp = SamplingParams(temperature=0.6, top_p=0.95, top_k=20, max_tokens=16384, stop=["<|im_end|>", "<|endoftext|>"])
print(llm.chat(msgs, sp)[0].outputs[0].text)
Evaluation
Thinking mode, temperature 0.6, top-p 0.95, top-k 20, 16,384-token budget, strict answer matching (a response cut off before the answer counts as wrong). Accuracy in %.
Evaluated checkpoint: the root weights (epoch 5, step 870). Intermediate checkpoints are not benchmark-evaluated.
| Benchmark | This model | Qwen3-4B-Base |
|---|---|---|
| AIME 2025 (avg@32) | 22.4 | – |
| AIME 2026 (avg@32) | 19.2 | 6.9 |
| AMC 2025 (avg@32) | 53.6 | 32.5 |
| MATH-500 (avg@8) | 81.1 | 69.3 |
| GPQA Diamond (avg@4) | 27.0 | – |
Checkpoints
- Root: final checkpoint (epoch 5, step 870).
intermediate/epochK_stepN/: earlier checkpoints, kept as-is.
Variants
variants/b … variants/e hold four more models trained the same way (same base, same problems, same schedule) on differently preprocessed versions of the same traces. Each has its own intermediate/ checkpoints. Load with subfolder="variants/b" in transformers, or download the folder for vLLM.
| Folder | AIME 2025 | AIME 2026 | AMC 2025 | MATH-500 | GPQA Diamond |
|---|---|---|---|---|---|
variants/b |
20.9 | 20.6 | 50.6 | 80.5 | 26.9 |
variants/c |
20.1 | 20.7 | 55.3 | 82.8 | 23.6 |
variants/d |
20.1 | 19.7 | 52.6 | 81.7 | 26.1 |
variants/e |
20.6 | 19.4 | 49.8 | 80.1 | 24.9 |
Limitations
A 4B model with long outputs: many hard-problem responses hit the 16k budget before answering. Math-only training; not tuned for chat safety or tool use.
- Downloads last month
- 514
Model tree for 96kevinli29/Qwen3-4B-R1-Distill
Base model
Qwen/Qwen3-4B-Base