Distillation from a stronger model
Train a smaller student on a teacher's outputs, either its full token distributions (soft targets via KL) or its sampled text. Explain why reasoning traces from a strong model transfer well to small models.
Builds on: Supervised fine-tuning on demonstrations, Chain of thought as extra computation
What the animation says
Big teacher, small student
You have a big, strong model, and you want a small one that is nearly as good but cheap to run. Ordinary training shows the small model one thing per position: the token that actually came next. But the big model knows more. At every position it can give a probability for every token in the vocabulary. Can that richer signal teach the small model better? And what if all you can get from the big model is text?
Soft targets carry more
Ordinary training uses a one-hot target: all the weight on cat, zero on everything else. The teacher's distribution says more: cat point six, kitten point two five, dog point one. It shows which alternatives are nearly right, and how uncertain this context is. So train the student to match the teacher's whole distribution. The gap is measured with KL divergence, averaged over positions. Every position now teaches something about every token, not just one. The catch: you need the teacher's logits and the same vocabulary.
The gradient: student minus teacher
For each token, the soft-target gradient on the student's logit is simply student probability minus teacher probability. With hard labels, the teacher's side is replaced by one for the observed token and zero elsewhere. That's the usual rule. Training steps against the gradient. A negative entry raises that logit; a positive entry lowers it. Three tokens, a, b, c. The teacher says point seven, point two, point one. The student says point five, point two five, point two five. Which logit will soft training push down the hardest? Tap it.
Hard label vs soft target
Now the hard label: observed token a, so the target is one, zero, zero. Student minus one-hot: minus point five, plus point two five, plus point two five. Soft: minus point two, plus point zero five, plus point one five. Hard pushes b and c down equally. Only soft says c is more overrated than b. Each entry compares one token, so a token where both agree gets zero. Now the teacher only returns text, no probabilities. What can you still do?
Text only: train on teacher samples
You can still distill. Send prompts, sample the teacher's responses, and run ordinary supervised fine-tuning on them. The loss is the usual one: minus log probability of each teacher token, given everything before it. This also works when the tokenizers differ, because only text crosses over. Averaged over samples, this equals the sequence-level KL from teacher to student, plus a constant: the teacher's entropy. The signal is thinner, though: one sampled token per position, instead of a full distribution.
Reasoning traces fit the budget
Teacher reasoning traces work especially well as text to train on. Each token the student produces gets a fixed amount of compute: about two operations per parameter, through a fixed number of layers. A hard answer can need more work than one token allows. Blurting it out in one step overloads that budget. A trace splits the work into small steps, and each step is a next-token prediction the student can afford. But teachers make mistakes. Keep only traces whose final answer checks out. Tap the one to throw away.
Soft targets carry more than the answer
Text only: SFT on teacher samples
The two distillation losses
Three tokens, hard vs soft
Remember
On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.
Bytewise
All courses