Model Distillation Explained: Shrinking Big AI Models

Model distillation explained simply is this: it is a way of training a smaller model, known as the student, to behave like a much larger model, known as the teacher, so that the small model keeps much of the big model’s skill while needing far less computing power to run. The central question is whether a small copy can really match the original, and the honest answer is that it usually comes close on the tasks it was trained for, but it cannot hold everything the large model knows.

Key takeaways

  • Distillation trains a small student model to copy a large teacher model, rather than training the small model from scratch.
  • The student learns from the teacher’s soft predictions, which carry more information than simple right-or-wrong answers.
  • Distilled models run faster and cheaper, and can work on ordinary devices without a powerful server.
  • Distillation is a trade-off: the student is usually weaker than the teacher on tasks outside its training.
  • The technique works best when the student only needs to be good at a defined set of tasks.

What model distillation is

A large AI model, such as a flagship language model, learns from vast amounts of text and can answer questions on an enormous range of subjects. That breadth is what makes it powerful, but it is also what makes it heavy: the model may contain so many parameters, the numbers it learned during training, that it needs specialist hardware to run. A student model is a much smaller model with far fewer parameters, which means it can run on a laptop, a phone or a modest server.

The idea behind distillation is that a small model does not need to repeat the teacher’s years of training from raw data. Instead, it learns directly from the teacher’s behaviour. The teacher is asked to answer a large set of examples, and the student is trained to produce the same answers. In this way, the knowledge the teacher gained from its huge training run is transferred into a compact form.

The concept was set out in a 2015 paper by Geoffrey Hinton, Oriol Vinyals and Jeff Dean, titled Distilling the Knowledge in a Neural Network. Their central insight was that a trained model knows more than its final answers show. When a model says an image is probably a dog, the fact that it also gave some weight to a cat tells the student something about how dogs and cats resemble each other. That extra information is the knowledge being distilled.

How distillation works: the teacher, the student and soft labels

Ordinary training gives a model hard labels: for each example, the correct answer is marked and every other answer is treated as equally wrong. Distillation replaces these with soft labels, which are the teacher’s full set of probabilities across all possible answers. If a teacher thinks a sentence is most likely positive in tone, but also gives some probability to neutral and a little to negative, the student sees all of that. The soft label carries far more information than a single correct answer, because it shows which answers are nearly right and which are wildly wrong.

A key part of the method is a setting called temperature, which controls how soft the teacher’s predictions are. At a low temperature, the teacher’s most likely answer dominates and the rest fade away. At a higher temperature, the differences between the less likely answers become clearer, so the student can see the fine structure of the teacher’s judgement. During training, the teacher’s predictions are softened with a higher temperature, and the student is trained to match them. The student is also usually trained on the true answers, so it learns both from the teacher and from the data itself.

The training itself follows a straightforward pattern. First, the teacher model is chosen, and a set of training examples is prepared that covers the tasks the student will need to do. Next, the teacher produces its predictions for every example. Then the student, which starts out untrained or lightly trained, is trained to match those predictions. Finally, the student is tested on examples it has not seen, to check how close it has come to the teacher. If the gap is too large, the training data or the size of the student may need to change.

Why distil a model

The most obvious reason is speed. A smaller model needs fewer calculations to produce each answer, so it responds faster. For a chat tool or a voice assistant, that difference is felt directly by the user. A model that answers in a fraction of a second feels responsive, while one that takes several seconds feels broken, however good its answers are.

The second reason is cost. Running large models requires powerful, expensive hardware, and the cost grows with every request. A distilled model can run on cheaper hardware, which makes it practical for a small business or a product with many users. This is also why distillation matters for privacy and reliability: a small model can run on a device itself, without sending data to a server. Our guide to edge AI explains how on-device models work, and why shrinking a model is often the step that makes them possible.

A photograph of a large server rack beside a small laptop on a desk, showing the contrast between heavy and lightweight computing
A distilled model moves the work from a large server to an ordinary device, trading some of the teacher’s breadth for speed, cost and portability.

Distillation compared with other ways to shrink a model

Method How it shrinks the model Main benefit Main drawback
Distillation A small model learns from a large one Keeps much of the teacher’s skill Needs the teacher and training data
Pruning Removes parts of the model that matter least Simple and keeps the same architecture Gains are limited before quality drops
Quantisation Stores numbers with less precision Runs faster with less memory Small loss of accuracy
Low-rank methods Replaces large matrices with smaller ones Big size reduction for some models Not suited to every architecture
Training small from scratch Builds a small model on raw data No teacher needed Usually weaker than a distilled model

Where distilled models are used

Distilled models are now common in everyday products. Voice assistants on phones often use distilled speech models, because the assistant must respond quickly and work even when the network is poor. Search and recommendation features use distilled models to rank results fast enough to keep up with users. Customer support tools use distilled chat models that have been trained to handle the questions a particular business receives, rather than every question a person might ask.

One well-known example is DistilBERT, a distilled version of the BERT language model published by the Hugging Face team in 2019. It was presented as a smaller and faster model that kept much of BERT’s ability on language understanding tasks, and it became widely used as a practical alternative to the full model. DistilBERT helped establish distillation as a standard engineering technique, rather than a research curiosity, and many later distilled models followed the same pattern. Our guide to AI model evaluation explains how claims like these are tested, and why a distilled model’s score should be checked on the tasks that matter rather than taken at face value.

The limits of distillation

The most important limit is that a student cannot know more than its teacher, and in practice it knows less. Distillation transfers the teacher’s behaviour on the training examples, not the teacher’s full understanding. A student trained on support conversations will be good at support, but it will not suddenly be able to answer questions about subjects the teacher was never asked about in training. Teams that distil a model for one job should expect it to be weaker outside that job, sometimes badly so.

Distillation can also pass on the teacher’s faults. If the teacher gives biased, inaccurate or unsafe answers, the student will learn to copy them. This is why the training examples matter so much: the teacher should be checked on the examples it will be distilled from, and bad answers should be filtered out before the student sees them. A distilled model is not automatically safer than its teacher; it is a smaller version of the same behaviour, faults included.

Model distillation checklist

  • Define the tasks the student must do well, and do not expect it to match the teacher everywhere.
  • Choose a teacher that is already strong on those tasks.
  • Prepare training examples that cover the real range of inputs, including awkward ones.
  • Check the teacher’s answers on those examples and filter out bad ones before training the student.
  • Use soft labels, with a temperature setting that reveals the teacher’s judgement between answers.
  • Pick a student size that fits the device it will run on, with room for the ability the task needs.
  • Test the student on unseen examples, and compare it with the teacher on the same tasks.
  • Combine distillation with other methods, such as quantisation, only after testing each step separately.
  • Plan to re-distil when the teacher improves or the tasks change, rather than treating the student as finished.

Frequently asked questions

What is model distillation?

It is a method of training a small model, the student, to copy the behaviour of a large model, the teacher. The student learns from the teacher’s predictions rather than only from labelled data, which lets it keep much of the teacher’s skill in a far smaller model that is cheaper and faster to run.

What is a teacher model?

The teacher is the large, capable model whose behaviour the student is trained to copy. It is run over a set of training examples to produce predictions, and those predictions become the training material for the student. The teacher is usually too large or expensive to use directly in the final product.

What are soft labels?

Soft labels are the teacher’s full set of probabilities across all possible answers, rather than a single correct answer. They carry extra information about which answers are nearly right and which are far wrong, and that information is what makes distillation more effective than training a small model from scratch.

What is temperature in distillation?

Temperature is a setting that controls how soft the teacher’s predictions are during training. A higher temperature spreads probability across more answers, revealing the fine differences in the teacher’s judgement. The student is trained to match these softened predictions, and the temperature is set back to normal when the model is used.

Is a distilled model always worse than its teacher?

On the tasks it was trained for, a distilled model can come close to the teacher, and it may even be better at the narrow job if the teacher’s faults are filtered out during training. On tasks outside its training, it is usually weaker, sometimes much weaker, because it has not learned the teacher’s breadth.

When should I use distillation instead of a small model trained from scratch?

Use distillation when a large teacher exists that is already good at the task, and when the student will be used often enough for the effort of creating it to pay off. If there is no suitable teacher, or the task is simple enough that a small model trained from scratch is good enough, distillation adds effort without much benefit.

The bottom line

Model distillation explained in one line is this: a small student model learns to copy a large teacher model’s behaviour, keeping much of its skill in a package that is fast, cheap and able to run on ordinary devices. It is a trade-off, not a free lunch: the student is narrower than the teacher and inherits its faults as well as its strengths. Used well, with clear tasks, clean training examples and honest testing, it is one of the most practical ways to take powerful AI out of the data centre and into the products people actually use.

Latest articles

Scroll to Top