Knowledge Distillation
Knowledge distillation trains a small, fast model to imitate a large, accurate one — not by copying its final answers, but by copying the full spread of confidence behind each answer, which carries far more information.
Prerequisites: Cross-Entropy and Log Loss, The Multilayer Perceptron
A senior trader can explain not just their trade, but how close a call it was — "I bought, but it was maybe 55/45 versus selling." A junior who only sees "buy" or "sell" written on a ticket learns far more slowly than one who hears the hesitation, the near-miss, the "I almost did the opposite." Knowledge distillation gives a small model that same richer signal: instead of learning only the correct label for each example, it learns the large model's full confidence distribution across every possible label, including the wrong ones.
A large, accurate model — the teacher — is expensive to run: too slow or too memory-hungry for production, live trading, or a mobile device. A student, a much smaller model, needs to approximate the teacher's behaviour cheaply. Training the student directly on the same labelled data the teacher used often falls well short of the teacher's accuracy, because the student has far less capacity to independently rediscover every pattern from raw labels alone. Distillation instead trains the student to match the teacher's output distribution.
Soft targets: the information hiding in "almost"
A classifier's raw output layer typically ends in a softmax, producing a probability for every class. A hard target — the label actually used for training with ordinary cross-entropy — collapses that to one number: for the true class, for everything else. A soft target keeps the teacher's full distribution: for an image that is mostly a cat, the teacher might output cat , dog , fox , car . That dog probability of is information: it says "this cat looks somewhat dog-like," a relationship the hard label throws away entirely.
Distillation controls how soft these targets are with a temperature applied inside the softmax:
Here is the teacher's raw pre-softmax score ("logit") for class , and is the resulting probability. In words: dividing every logit by before exponentiating shrinks the differences between them when , spreading probability mass more evenly across all classes — turning a confident output into something like , which reveals the relative similarity between the wrong classes that a near-certain prediction hides. At you get the ordinary softmax; as the distribution flattens toward uniform.
Drag the curve's steepness parameter and watch a sharp S-curve flatten into a gentle slope — that's the same effect temperature has on a softmax: a high, confident peak (steep curve) versus a spread-out, informative distribution (gentle curve) over the same set of classes.
The student is trained on a weighted combination of two losses: the usual cross-entropy against the true hard label, and a second cross-entropy against the teacher's softened () probabilities. The second term is what transmits the teacher's "hesitation."
Worked example 1: soft vs hard target for one example
An image is truly a "call option payoff" chart. The teacher's raw logits (before softmax) for three classes {call payoff, straddle payoff, put payoff} are . At : , , , sum , giving probabilities — already fairly informative, since call and straddle are close. At : divide logits by 4 first, , then , , , sum , giving . The gap between "call" and "straddle" shrank from 24 points to 5 points of probability, and "put" — genuinely a much less similar shape — still trails clearly. The student now sees, in one training example, "this looks like a call, quite a bit like a straddle, and not much like a put," instead of just "this is a call."
Worked example 2: why the student can beat training on hard labels alone
Suppose a small student trained directly on 1,000 hard-labelled examples reaches 82% accuracy — it lacks capacity to fully separate every class from raw labels alone. The same architecture trained via distillation on the identical 1,000 images, using a large teacher's soft outputs, reaches 89%. The extra 7 points didn't come from new data; they came from the teacher compressing what it learned from millions of examples into the shape of its outputs on those same 1,000 images, and the student absorbing that shape instead of rediscovering class relationships from scratch.
Distillation transfers a large model's knowledge not through its weights but through the shape of its predictions — softened, so that the relationships between wrong answers become visible training signal instead of being thrown away as zero.
What this means in practice
Distillation is how a quant firm gets a large, slow model — an ensemble, a big gradient-boosted forest — into something that can score thousands of instruments in real time. It's standard for compressing large language models into deployable assistants, and equally applicable to compressing a slow research ensemble into a fast, small-network approximation usable intraday.
A distilled student can never exceed the information the teacher provides, only get closer to matching it — distillation is compression, not a way to create accuracy the teacher didn't have. If the teacher is confidently wrong (miscalibrated or overfit to its own training data), the student inherits those exact mistakes, sometimes amplified, because it was explicitly trained to reproduce them. Always validate the student independently against ground truth, not just against the teacher's outputs.
Related concepts
Practice in interviews
Further reading
- Hinton, Vinyals & Dean, Distilling the Knowledge in a Neural Network (2015)
- Bucila, Caruana & Niculescu-Mizil, Model Compression (2006)