What Is Model Distillation, and How Does It Work?
Model distillation trains a small, fast model to copy a large one. It keeps most of the quality while cutting the cost and latency of running the model.
On this page
Short answer
Model distillation is a training method where a large teacher model shows a smaller student model how to answer, and the student learns to copy the teacher's outputs. The student trains on the teacher's answers, including its confidence, rather than only on fixed right answers. The result is a smaller model that runs faster and costs less, and is often close to the teacher on the tasks it trained for.
What is model distillation?
Model distillation is a way to shrink a large AI model into a smaller one that behaves almost the same way. A big model, called the teacher, answers a large set of examples. A small model, called the student, trains on those answers until it can produce similar ones on its own. The student ends up far smaller and cheaper to run, while keeping much of the teacher's skill on the tasks it practised.
The idea is simple: a large model knows a lot, but most of that knowledge is not needed for one job. A support team does not need a model that can write poetry; it needs one that can sort tickets and draft replies. Distillation keeps the part of the teacher's skill that matters for the job and drops the rest.
Distillation is not the same as compressing a file. The student is a new model with fewer parameters, trained from scratch on the teacher's behaviour. It does not contain a copy of the teacher, and it cannot do everything the teacher can. It is good at the tasks it was distilled for, and weaker outside them.
How does distillation work?
Distillation works by turning the teacher's answers into training data. The team picks a set of inputs that match the real job, runs the teacher on each one, and records what it produced. The student then trains on those pairs of inputs and teacher outputs, learning to give the same answers.
The key detail is that the teacher's answers carry more information than a simple right or wrong label. A classification teacher does not only say which class is right; it also says how likely each other class is. Those near-misses tell the student which answers are close and which are far apart, which is far more useful than a single correct label.
A common trick is to soften the teacher's outputs with a setting called temperature. A higher temperature spreads the teacher's confidence across more options, so the student sees the full shape of the teacher's judgement. The student is then trained with that softened output, and at run time it uses its normal, sharper answers.
The data matters more than the trick. If the examples do not match the real job, the student learns the wrong behaviour. Teams usually build the training set from real requests, with private data removed, and add edge cases the teacher handled badly so the student can learn from them too.
When should a team use distillation?
Distillation fits when a large model works well but costs too much to run at scale. A team that serves millions of requests a month pays for every token the large model reads and writes, and a smaller model can cut that bill sharply while keeping the answers close enough for the job.
Speed is the second reason. A small model answers faster, which matters for live products such as chat, search and voice. When a user waits for a reply, a model that answers in half a second beats one that answers in three, even if the slower one is slightly better.
The third reason is where the model runs. A distilled model can fit on a single server, a phone, or a device with no internet connection, while a large model needs a data centre. For products that must work offline or inside a private network, a small model is often the only option.
Distillation does not fit when the task changes often or needs broad knowledge. A student trained for one job will not handle a new job well, and retraining takes time. In that case, calling the large model directly is simpler, even if it costs more per request.
What does distillation cost, and what does it save?
Distillation has a one-off training cost and a running saving. The team pays to run the teacher over the training examples, pays for the student's training, and pays for testing. After that, each request costs less, so the saving grows with volume.
| Item | Teacher only | Distilled student |
|---|---|---|
| Cost per request | High | Much lower |
| Answer speed | Slower | Faster |
| Where it runs | Data centre | Small server or device |
| Up-front work | None | Training and testing |
| Works on new tasks | Yes | Only tasks it trained for |
The maths is simple: multiply the saving per request by the number of requests a month, and compare it with the one-off training cost. A team with low volume may never recover the training cost, while a team with high volume can pay it back in weeks. For how to test a model before committing, see how to test AI models.
Example (hypothetical): shrinking a support classifier
Example (hypothetical): a shop uses a large model to sort 1,000,000 support messages a month. The large model costs $0.004 per message, so the monthly bill is 1,000,000 x $0.004 = $4,000. The team decides to distil a smaller model for this one job.
They collect 50,000 real messages, remove names and order numbers, and run the teacher over them. That run costs $500. Training the student on those answers costs $1,500, and testing it on a labelled set costs $0 in model calls, since the test set is small. The total one-off cost is $500 + $1,500 = $2,000.
The student costs $0.0004 per message, so the new monthly bill is 1,000,000 x $0.0004 = $400. The saving is $4,000 - $400 = $3,600 a month, so the $2,000 training cost is paid back in less than one month: $2,000 / $3,600 = 0.56 months, or about 17 days.
The student is not perfect. On the test set it sorts 92 of 100 messages correctly, while the teacher sorts 95 of 100. The team accepts that gap because the 3 extra errors per 100 are caught by the human review step, and the saving is $3,600 a month. If the gap had been larger, they would have kept the teacher.
How do you run a distillation project?
A distillation project is a short, focused piece of work. The team picks one job, builds the training data, trains the student, and tests it against the teacher before switching anything over.
- Pick one narrow job. Choose a task with clear inputs and outputs, such as sorting messages or drafting replies, not a general assistant.
- Build the training set. Collect real examples, remove private data, and add the edge cases the teacher handles badly.
- Run the teacher. Record its answers and its confidence on each example, and keep the raw outputs for later checks.
- Train the student. Start from a small base model and train it on the teacher's outputs until its test scores stop improving.
- Test against the teacher. Run both models on a labelled set the student never saw, and compare accuracy, speed and cost per request.
- Ship with a fallback. Send hard cases to the teacher and log them, so the team can see where the student still struggles.
The fallback matters. A student that quietly gives wrong answers is worse than a slow teacher, so the team should route low-confidence cases to the teacher or to a person. For how to plan the first test, see how to build an AI proof of concept.
What are the common mistakes?
The most common mistake is distilling for the wrong task. A student trained on short, simple requests will fail on long, messy ones, because it never saw them in training. The training set must match the real job, including the hard cases.
Another mistake is testing on the training data. A student can score well on examples it already saw while failing on new ones, so the test set must be separate and labelled by people, not by the teacher.
Teams also forget to check what the student loses. A teacher that is good at many things can hide a weakness: the student may copy the teacher's answers on the test set while missing a whole class of inputs the team never tested. Test by input type, not only by overall score.
Finally, do not distil a model you do not have the right to copy. Some model providers forbid using their outputs to train a competing model, so check the licence and terms before starting. The teacher's answers are its output, and the rules around them are part of the project. Retrieval quality also affects what the teacher sees; see what retrieval augmented generation is for that layer.
Key takeaways
- Distillation trains a small student model to copy a large teacher's answers.
- The teacher's confidence levels teach the student far more than right-or-wrong labels.
- Use it when volume is high, speed matters, or the model must run on small hardware.
- Compare the one-off training cost with the monthly saving per request.
- Ship with a fallback: route low-confidence cases to the teacher or a person.
Frequently asked questions
What is model distillation in simple terms?
Model distillation is a training method where a large teacher model answers many examples and a smaller student model learns to give the same answers. The student ends up far smaller and cheaper to run, while keeping much of the teacher's skill on the tasks it was trained for. It cannot do everything the teacher can.
How is distillation different from fine-tuning?
Fine-tuning trains a model on labelled right answers for one task. Distillation trains a student on a teacher model's answers, including how confident the teacher was about each option. The extra information about near-miss answers helps the student learn faster and reach closer to the teacher's quality.
How much quality does a distilled model lose?
It depends on the task and the size gap. For a narrow job with good training data, a student can come within a few points of the teacher on a test set. For broad or open-ended work the gap is larger. The only way to know is to test both models on a labelled set the student never saw.
Can a distilled model run on a phone?
Yes, if it is small enough. Distilled models are often used on phones, single servers and devices with no internet connection, because they need far less memory and compute than the teacher. The exact size depends on the task and the hardware, and the team should test on the real device.
Do you need the teacher's training data to distil it?
No. Distillation uses the teacher's outputs on a set of inputs, not the data the teacher was trained on. The team supplies the inputs, usually real requests with private data removed, and records what the teacher produces. The quality of those inputs decides how good the student becomes.
Is it legal to distil a model from another provider?
It depends on the provider's terms. Some model providers forbid using their outputs to train a competing model, while others allow it. Check the licence and terms of the teacher model before starting a distillation project, and keep a record of what was used.