Topic 3 of 5 · 5 min read
Distilling reasoning traces into small models
Goal: Judge from eval results whether a small model distilled on reasoning traces is reliable enough for a stated task.
A reasoning trace is the step-by-step working a reasoning model writes before its answer; training a small model on those traces teaches it to write similar working, but not necessarily to reason as well.
Check yourself · 1 of 3
What does a small model distilled on reasoning traces learn to do?
Why it matters
Reasoning models such as DeepSeek-R1 write long chains of thought before the final answer. That raises accuracy on maths, code and logic, and also cost and latency. Distilling those traces into a 7B or 14B model promises some of the benefit on hardware you can afford. The DeepSeek-R1 paper reports that fine-tuning smaller Qwen and Llama models on R1's outputs beat running reinforcement learning on those same small models, and the released distilled models follow that recipe.
How the recipe works
- Collect prompts with checkable answers: maths problems, code with tests, logic puzzles.
- Sample the teacher several times per prompt and keep the full trace plus the answer.
- Filter by correctness: keep traces whose final answer is verified. Drop the rest, and drop traces that are malformed, mix languages or loop.
- Run supervised fine-tuning of the student on prompt, trace and answer.
- Evaluate on held-out problems, with several samples per problem.
Note that the student learns from text. It sees the steps, not the process that produced them.
Before and after
Weak claim: "The distilled 7B shows its working, so we can trust it for checking loan calculations." The visible working only shows what the model wrote. Better: "On our 300 held-out calculations the 7B student is correct on 81% of runs against the teacher's 93%. Wrong answers often come with confident, tidy steps. We use it for drafts and verify the result with code."
The limits of copied reasoning
- Looks right, is wrong. A student can imitate the style of a derivation, including confident wrong steps. Plausible steps are not a check.
- Narrow transfer. Gains are strongest on problem types in the training traces. A shift in format or domain can remove them.
- Long output cost. A student that thinks in 3,000 tokens is cheaper per token than the teacher but may still be slow or costly per request.
- Variance. Some runs reach the answer and some loop or stop early, so judge by accuracy over several samples, not one lucky run.
- Teacher errors. Traces with a right answer reached by a wrong route still pass an answer-only filter.
What to look at before shipping
Compare accuracy on your own task with the teacher, look at failures by category, check the length of outputs and the rate of loops, and decide what happens when it is wrong. A student that is fine for a first draft can be unfit for an unattended decision.
Examples
Reading an eval before shipping
A team compares models on 300 held-out unit-conversion and tax calculations, five samples each:
| Model | Correct runs | Median output tokens | Loops |
|---|---|---|---|
| Teacher reasoning model | 93% | 2,400 | 0% |
| Distilled 7B | 81% | 3,100 | 4% |
| Untuned 7B | 52% | 400 | 0% |
The student closes most of the gap, but 19% wrong is too many for unattended use, and it writes longer traces than the teacher. It becomes a draft step with a code check.
Right answer, wrong route
A trace multiplies by 0.8 where it should divide by 1.25 and still lands on the right number for this input. An answer-only filter keeps it. The student learns a rule that fails on other inputs. Verifying with unit tests on varied inputs catches more than checking one answer.
Key points
- A reasoning trace is the written step-by-step working before the answer, and the student is trained to write similar working.
- Filter teacher traces by verified answer correctness and drop malformed, looping or mixed-language ones before training.
- Fine-tuning on a strong reasoning model's traces beat reinforcement learning on the small model itself in the DeepSeek-R1 report.
- Visible steps from a student are text it wrote, not proof of correct reasoning, so measure accuracy over several samples.
- Decide shippability from your own held-out task, the failure types, output length and what a wrong answer costs.
Common mistakes
- Trusting a student's tidy step-by-step working as evidence that its answer is correct.
- Judging the student on one sample per problem instead of several.
- Building the training set from traces whose answers were never checked.
- Assuming gains on maths and code problems carry over to a different domain.
Check yourself · 2 of 3
You build a trace set for maths problems. Which filter is most important before fine-tuning?
Check yourself · 3 of 3
A distilled 7B gets 78% of runs correct on your task, the teacher 91%. Wrong answers come with neat steps. What is the sensible use?
Practice items, not counted towards your mastery.
Start here
- Distilling the Knowledge in a Neural Network (opens in a new tab)PaperFree
The original soft-target and temperature recipe that every later distillation method builds on.
- DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning (opens in a new tab)PaperFree
Reports distilling a large reasoning model's outputs into smaller Qwen and Llama models, and compares that with running RL on the small model.
- Hugging Face TRL: Generalized Knowledge Distillation Trainer (opens in a new tab)DocsFree
A working trainer for logit distillation with the loss and sampling options explained.
More for this topic
- DeepSeek-R1-Distill-Qwen-7B model card (opens in a new tab)DocsFree
A real distilled model with its base model, licence and recommended usage notes.