Model Distillation Explained: Smaller Models From Bigger Ones

Model distillation trains a small student model to copy a large teacher's full output. Soft targets, temperature, DistilBERT results, and a five-step workflow.

By Galactic News Editorial · Published 2026-11-17T10:30:45+00:00 · Updated 2026-11-17T10:30:45+00:00

Model distillation explained: a large teacher model training a smaller student model

Model Distillation Explained: Smaller Models From Bigger Ones

Model distillation trains a small model to copy a large one. The large model is the teacher. The small model is the student. The student learns from the teacher's full output, not just its final answer. The result is a model that is far smaller and faster, yet keeps most of the teacher's skill. This guide explains how distillation works, why it works, and when to use it.

Model Distillation Explained in One Idea

A large model knows more than its top answer. When it classifies an image, it assigns a probability to every class. Those probabilities carry information. A handwritten 2 is more like a 3 than a 7. That ranking is what researchers call dark knowledge. Hard labels throw it away. Distillation keeps it.

The method comes from a 2015 paper by Geoffrey Hinton, Oriol Vinyals, and Jeff Dean at Google. The paper is titled Distilling the Knowledge in a Neural Network. Its core trick is simple. Raise the temperature of the teacher's softmax function. A high temperature softens the output distribution. Small probabilities become visible. The student trains on those soft targets. Then it runs at normal temperature in production.

The temperature is the key control. At temperature 1, the output looks like a confident answer. At a higher temperature, the ranking of the wrong answers shows through. The student learns the teacher's judgment, not only its verdict. That is why distillation beats training the same small model on hard labels alone.

What the Original Paper Proved

Hinton and his co-authors tested distillation on MNIST, the handwritten digit task. A large regularized network made 67 test errors. A smaller network trained the usual way made 146 errors. The same small network trained with distillation made 74 errors. It nearly matched the teacher with a fraction of the size.

The paper also tested a speech model. An ensemble of ten acoustic models reached 61.1 percent frame accuracy. A single model distilled from that ensemble reached 60.8 percent. The distilled model kept almost all of the ensemble's gain. It was far easier to deploy.

Distillation also worked when the training data lacked examples of a class. The teacher's soft targets still carried information about the missing class. The student learned to recognize digits it had never seen labeled. That result surprised even the authors. It showed how much knowledge lives in the teacher's probabilities.

DistilBERT: The Classic Example

The most widely used distilled model is DistilBERT. Hugging Face researchers published it in 2019. They distilled BERT-base, a 110-million-parameter model, into a 66-million-parameter student. The student kept 6 of the teacher's 12 layers. It was initialized from every other teacher layer.

The training used a triple loss. The first term matched the teacher's soft targets. The second was standard masked language modeling. The third aligned the hidden states of student and teacher with a cosine loss. Training ran on 8 V100 GPUs for about 90 hours. The corpus was the same as BERT's: English Wikipedia plus the Toronto Book Corpus.

The results set the standard for compression. DistilBERT has 40 percent fewer parameters than BERT-base. It runs 60 percent faster on CPU. It retains 97 percent of BERT's language understanding, scoring 77.0 against 79.5 on the GLUE benchmark. On an iPhone 7 Plus, a question-answering model built on DistilBERT ran 71 percent faster than the BERT version. The whole model weighs 207 megabytes.

How to Distill a Model in Five Steps

  1. Pick the teacher. Choose the best model you can run, even if it is too big to deploy. Its quality sets the ceiling for the student. A weak teacher produces a weak student.
  2. Build the transfer set. Gather the inputs the student will see in production. Unlabeled data works. The teacher provides the labels through its soft targets.
  3. Choose the student. Pick an architecture that fits the deployment budget. Halving the layers is the usual starting point. Keep the hidden size the same when possible.
  4. Set the temperature and the loss. Train the student on soft targets at a high temperature, plus the hard labels. Add a hidden-state matching term when the architectures align. Tune the temperature on a validation set.
  5. Evaluate against the teacher. Compare the student with both the teacher and a baseline trained on hard labels only. Ship the student only if it beats the baseline by a clear margin on real inputs.

Modern large language models use the same pattern at a larger scale. DeepSeek's R1 team fine-tuned distilled models on about 800,000 curated samples from its reasoning model. Google's Gemma 2 models were also trained with knowledge distillation. The recipe scales from digits to reasoning models.

Distillation vs Other Compression Methods

MethodWhat it doesStrengthWeakness
DistillationTrains a small student on a large teacher's outputsKeeps most accuracy; works across architecturesNeeds a trained teacher and a transfer set
PruningRemoves weights or neurons from a trained modelNo retraining from scratchGains depend on redundancy; can hurt accuracy
QuantizationReduces weight precision, often to 8-bit integersFast to apply; big memory savingsSmall accuracy loss; hardware support varies
Architecture designBuilds a small model from the startCleanest deployment storyCannot borrow a big model's knowledge

These methods combine well. DistilBERT can be quantized after distillation. A pruned model can be distilled again. Most production small models use two or more of these techniques together.

When Distillation Is the Wrong Choice

Distillation has real limits. The student cannot exceed the teacher. If the teacher is wrong, the student inherits the error. A teacher trained on one domain will not distill well into another. The transfer set must match the deployment data, or the student learns the wrong distribution.

Licensing is the other constraint. Distilling from a model you do not own may breach its terms. Check the teacher model's license before using its outputs as training data. Open models such as BERT and Gemma carry permissive terms. Hosted commercial models often restrict distillation in their terms of use. Read the terms first.

Cost also matters. Distillation needs the teacher's inference over the whole transfer set, plus the student's training run. For a small task, fine-tuning a small pre-trained model directly may be cheaper and just as good. Distillation pays off when the teacher is much stronger than anything small you could train directly.

Bottom Line

Model distillation turns a large model's knowledge into a small, deployable model. The teacher's softened probabilities teach the student more than hard labels ever could. DistilBERT proved the idea at scale: 40 percent smaller, 60 percent faster, 97 percent of the performance. Use distillation when you have a strong teacher, a matching transfer set, and a deployment budget the teacher cannot meet. Check the license, validate on real inputs, and ship the student only when it clearly beats the baseline.