What is distillation?
A large model teaches a smaller one
A teacher and a student
Distillation is a way of training a smaller model, the student, on what a larger model, the teacher, already knows how to do. The student does not have to discover the skill from a blank page. It practises on the teacher’s work.
Think of an experienced tutor sitting next to a junior student. The tutor does not only tick the final answer. They talk the problem through out loud: what they notice first, which path they try, where they check themselves, and how they write the answer at the end. The junior student learns that way of talking through the work, not just the number at the bottom of the page.
The large model is the tutor. The small model is the junior student. The written walk-through is the training text.
That is the whole idea, and it is older than today’s reasoning models. What has changed is what the teacher hands over: sometimes a soft distribution over answers, and sometimes a full written solution, traces and all.
Soft labels, and then traces
The classic recipe, from 2015, is soft labels. The teacher is not forced to pick a single class. It may say “mostly cat, a little dog, almost never car”. That softness is useful: it tells the student how the teacher is unsure, and which mistakes are close to being right. The student is trained to match that distribution, usually by a KL divergence on the probabilities.
A reasoning model can hand over something else: not only a soft guess at the next token, but the trace of how it got there. The teacher writes a solution, often inside <think>…</think> tags, and then a final answer. The student is trained on that text, as if the tutor’s monologue were the ground truth. That is how the smaller DeepSeek-R1 variants were trained, and it is the approach taken in the lab that follows this page.
The two ideas are cousins, not rivals. Soft labels pass on the shape of the teacher’s uncertainty at each choice. Traces pass on a path the teacher took through the problem. You can use one, or the other, or both.
Hard, soft, and combined
Once you have a teacher and a student, there are three common ways to write the loss.
Hard distillation trains the student on the teacher’s output tokens with ordinary cross-entropy. In practice this is supervised fine-tuning on synthetic text. You do not need the teacher’s logits, only the text. That is what you can do when the teacher is a closed API, and it is what the lab implements.
Soft distillation trains the student to match the teacher’s probability distribution, typically with \(\mathrm{KL}(p_{\text{teacher}} \,\Vert\, p_{\text{student}})\). That needs the teacher’s logits, or at least its log-probabilities, at training time, and it needs the two models to share a tokenizer. If the vocabularies do not line up, the distributions are not about the same things.
Combined distillation is the 2015 recipe: the hard tokens, plus a weighted KL term, \(L = \mathrm{CE} + \lambda\,\mathrm{KL}\). When both signals are available, a carefully designed soft objective can outperform hard labels alone. In today’s LLM practice, hard distillation is the more common choice, because full logits are often hidden, expensive to store, or blocked by a provider’s policy.
A tiny live cell that computes both losses on three tokens sits in Lab#LL01-1: Distilling a reasoning model. It is meant to make the difference felt, not to train a language model.
Why distill a reasoner?
A reasoning model is often expensive to run. Distillation is one way to keep much of the behaviour in a model that is cheaper to serve.
There is a second, more interesting claim. For a small model, learning from a strong teacher’s traces can work better than trying to acquire the same skill only by reinforcement learning with a verifier (RLVR) from scratch. The DeepSeek-R1 work reported that pattern for its smaller variants: the large 671-billion-parameter model was trained first, and the smaller ones were then distilled from it.
RLVR is like practising with a marking scheme. The student writes an answer, a checker says right or wrong, and the student is nudged from that signal. Distillation is like copying how a good tutor thinks aloud. You still care that the answer is right, but the training signal is the teacher’s solution, not only a tick or a cross.
The two can be complementary. The lab stays with distillation.
In one table
| Idea | In one sentence |
|---|---|
| Distillation | Train a smaller student on the work of a larger teacher |
| Soft labels | The teacher hands over a distribution, not only a single class or token |
| Reasoning traces | The teacher hands over a written solution, often inside <think> tags |
| Hard loss | Cross-entropy on the teacher’s tokens; no logits required |
| Soft loss | KL on the teacher’s distribution; needs logits and a shared tokenizer |
| Combined loss | \(\mathrm{CE} + \lambda\,\mathrm{KL}\), the 2015 knowledge-distillation recipe |
| Why bother | A smaller model is cheaper to run, and can learn a skill from traces more easily than from a verifier alone |
FAQ
Is distillation the same as compression? It is a way of passing behaviour from a large model to a smaller one. The student is a new model, trained, not a zipped copy of the teacher’s weights.
Do I always need the teacher’s logits? No. Hard distillation only needs the teacher’s text. Soft distillation needs the distribution, so you need logits or log-probabilities, and a shared vocabulary.
Is the teacher’s answer always right? No. A teacher can be confidently wrong. Distillation copies the teacher’s style of solution. A later check against a ground-truth answer, as in the lab’s MATH numbers, is how you see whether that style is also accurate.
Where should I go to try this? The short reference stops here. The step-by-step walk-through is Lab#LL01-1: Distilling a reasoning model. The tiny cells there run in the browser; the 0.6B training run does not.
See also
References
- [1] Sebastian Raschka, Build a Reasoning Model (From Scratch), Manning, ISBN 9781633434677. Publisher. Code: rasbt/reasoning-from-scratch (Apache License 2.0). Chapter 8, Distilling Reasoning Models for Efficient Reasoning, and the walk-through video.
- [2] Geoffrey Hinton, Oriol Vinyals and Jeff Dean, Distilling the Knowledge in a Neural Network, 2015. https://arxiv.org/abs/1503.02531.
- [3] DeepSeek-AI, DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning, 2025. https://arxiv.org/abs/2501.12948.
- [4] Sebastian Raschka,
math_distilldataset. https://huggingface.co/datasets/rasbt/math_distill. The problems come from MATH, excluding the MATH-500 test items (math_full_minus_math500).





