AI
Model Distillation: How Small Models Learn From Big Ones
Model distillation trains a small student model to copy a large teacher. How knowledge distillation works for LLMs, vs fine tuning, and attacks.
Model distillation is a way to train a small, cheap AI model (the student) to copy the behaviour of a large, expensive one (the teacher). Instead of learning only from raw data, the student learns from the teacher's answers or probabilities, so it can keep much of the teacher's skill at a fraction of the size, cost and latency. Many of the small open models you can run on a laptop, and many "mini", "flash" and "turbo" models, were made this way.
This guide explains how model distillation works, the main types of knowledge distillation, how LLM distillation is done in practice, real examples, model distillation vs fine tuning and quantization, and what a distillation attack is.
What Is Model Distillation?
Model distillation, also called knowledge distillation, transfers what a large model has learned into a smaller one. The idea was popularised in a 2015 paper by Geoffrey Hinton, Oriol Vinyals and Jeff Dean, "Distilling the Knowledge in a Neural Network".
Their key insight: a trained model's output contains more information than just the right answer. When an image model sees a photo of a dog, it might say "dog 90%, wolf 8%, cat 2%". Those small probabilities tell you that a dog looks more like a wolf than a cat. A student trained to match the whole set of probabilities (the soft targets) learns this structure, while a student trained only on the label "dog" (the hard target) does not.
How Knowledge Distillation Works
A basic knowledge distillation setup has four parts:
- A teacher: a large, accurate model, already trained.
- A student: a smaller model, often with the same kind of architecture but fewer layers or parameters.
- Training inputs: examples of the task, which can be the original training data or new data.
- A loss that compares the two: the student is trained to make its outputs match the teacher's outputs, often combined with the normal loss on the correct answers.
A setting called temperature softens the teacher's probabilities so the small ones become more visible during training. Here is an illustration with made-up numbers for one image:
| Class | Hard label | Teacher at normal temperature | Teacher at higher temperature |
|---|---|---|---|
| Dog | 1 | 0.90 | 0.60 |
| Wolf | 0 | 0.08 | 0.28 |
| Cat | 0 | 0.02 | 0.12 |
The higher-temperature version tells the student much more about how the teacher "sees" the image, which is the knowledge being distilled.
Types of Knowledge Distillation
Researchers group knowledge distillation by what the student copies:
- Response-based: the student matches the teacher's final outputs, such as class probabilities or next-token probabilities. This is the classic Hinton approach.
- Feature-based: the student also matches the teacher's internal activations (hidden states) at certain layers, learning how the teacher represents things, not just what it answers.
- Relation-based: the student learns the relationships the teacher sees between examples or between layers.
And by how training is organised:
- Offline distillation: the teacher is fixed and already trained; the most common setup.
- Online distillation: teacher and student train at the same time.
- Self-distillation: a model teaches itself, for example deeper layers teaching shallower ones, or a model trained on its own improved outputs.
How LLM Distillation Works
LLM distillation uses the same idea on language models, and there are three main ways to do it.
Logit distillation (white-box)
At every position in a text, an LLM outputs a probability for each possible next token. In logit distillation, the student is trained to match the teacher's full next-token distribution, token by token. This passes on the most information, but you need access to the teacher's weights or full output probabilities, and both models generally need the same tokenizer. Meta used this approach for the Llama 3.2 1B and 3B models: it pruned them from Llama 3.1 8B, then used the logits of Llama 3.1 8B and 70B as token-level targets during pre-training.
Data distillation (black-box)
If you can only see the teacher's text, not its probabilities (as with a commercial API), you generate a large dataset of prompts and teacher answers, then fine-tune the student on it. This is also called sequence-level distillation, and it overlaps with training on synthetic data. It is the most common form of LLM distillation in practice, because it works with any teacher. DeepSeek used this route for its R1 distilled models: it fine-tuned Qwen2.5 and Llama 3 base models from 1.5B to 70B parameters on reasoning data generated by DeepSeek-R1 (800,000 curated samples for the Qwen-based versions).
On-policy distillation
In the first two methods the student copies the teacher's answers. In on-policy distillation the student writes its own answers and the teacher scores each token, so the student learns to fix its own typical mistakes. It sits between distillation and reinforcement learning, and it tends to help small models stay on track over long outputs.
Model Distillation Examples
- DistilBERT: a 2019 distilled version of Google's BERT that, according to its authors, is 40% smaller and 60% faster while keeping 97% of BERT's language understanding.
- Llama 3.2 1B and 3B: pruned from Llama 3.1 8B and trained with logits from the 8B and 70B models, built to run on phones and edge devices.
- DeepSeek-R1 distilled models: six open models (1.5B to 70B) that learned step-by-step reasoning from DeepSeek-R1's outputs.
- Gemma 2: Google trained its smaller Gemma 2 sizes with knowledge distillation from a larger model.
- Fast image generators: "turbo" image models generate in one to a few steps instead of dozens by distilling a slower diffusion model.
- Your own task model: a company can distil a frontier model's answers on, say, support ticket classification into a small model that runs cheaply on its own servers.
Reasoning Distillation: Teaching Small Models to Think
A big recent use of LLM distillation is passing on reasoning, not just answers. Instead of training the student on the teacher's final answer alone, you train it on the teacher's step-by-step working (its chain of thought), so the student learns how to reach answers.
- Distilling step-by-step: a 2023 Google paper trained small models on both labels and the rationales a large model wrote for them. Its 770M-parameter T5 student beat the few-shot prompted 540B PaLM on one benchmark while using only 80% of the training data, which standard fine-tuning of the same small model could not match even with all of it.
- Reasoning model distills: DeepSeek's R1 distilled models learned long step-by-step reasoning purely from fine-tuning on R1's outputs, giving small open models much stronger maths and coding skills than their base versions.
The catch: reasoning traces are long, so generating them costs more teacher tokens, and the student also learns to "think" at length, which makes its answers slower. See our explainer on the small language model for where this trade-off makes sense.
Model Distillation vs Fine Tuning
Model distillation vs fine tuning confuses many people, because data distillation uses fine-tuning:
- Fine-tuning adapts a model to your task using example data. The examples can come from humans, from your logs, or from another model. Our guide to fine-tuning vs RAG explains when fine-tuning is worth it at all.
- Distillation is about where the training signal comes from: a stronger teacher model. The goal is to make a smaller model behave like the bigger one.
So "distillation" describes the goal and the source of the labels; "fine-tuning" describes the training step. If you fine-tune a small model on answers written by a large model, you are doing both.
Distillation vs Quantization and Pruning
Distillation is one of three common ways to make models smaller and faster, and they combine well:
| Method | What it does | Needs training? | Typical result |
|---|---|---|---|
| Distillation | Trains a new, smaller model to copy a larger one | Yes, often a lot | A different, smaller model with much of the teacher's skill |
| Quantization | Stores the same model's weights in fewer bits | No (or light calibration) | Same model, less memory, small quality loss |
| Pruning | Removes less important weights, layers or neurons | Usually, to recover quality | A slimmer version of the same model |
Llama 3.2 is a good example of combining them: pruning first, then distillation to recover quality, and many people then run a quantized version on their own devices.
When Should You Distil a Model?
Distillation pays off when:
- You have a narrow, repeated task (classification, extraction, routing, a fixed style of answer) and high volume.
- A big model already does it well, but costs too much or is too slow per request.
- You need it to run locally: on a phone, a laptop, or your own servers for privacy. Small models are good at narrow jobs, not everything.
It is usually not worth it when traffic is low, the task keeps changing, or you need broad general knowledge: a small model can copy a skill, but it cannot hold everything a large model knows.
A simple LLM distillation recipe
- Define the task and a test set of real examples with correct answers.
- Measure the teacher on the test set to set the quality bar.
- Generate training data: run the teacher on thousands of real or realistic inputs. Filter out wrong or low-quality answers.
- Fine-tune the student on the filtered pairs (LoRA is often enough for small tasks).
- Evaluate the student on the same test set, plus edge cases, and compare cost and latency.
- Iterate: add examples where the student fails, and keep a fallback to the teacher for hard cases.
Check the teacher's terms of service first: major AI providers' terms forbid using their outputs to build models that compete with them, and some provide their own managed distillation tools.
Tools for Model Distillation
You don't need to build a distillation pipeline from scratch:
- Hugging Face TRL: its GKD trainer implements on-policy distillation (Generalized Knowledge Distillation). You pass a student and a teacher model, and settings control how much training uses the student's own generated text and which loss compares the two. It needs access to both models' weights.
- Plain fine-tuning tools: for data distillation, any supervised fine-tuning tool works, because the job is simply training on teacher-written examples. LoRA-based tools keep the cost low.
- Managed services: Amazon Bedrock Model Distillation takes your prompts, generates teacher responses (or reuses responses from your invocation logs), and fine-tunes a smaller student model in one workflow. Other platforms offer similar features; check which teacher and student models each supports.
- Evaluation tools: distillation is only as good as your tests. Keep a fixed test set and compare teacher and student on it before you switch any traffic.
What Is a Distillation Attack?
A distillation attack is when someone distils a model without permission: they send huge numbers of queries to a commercial model, collect its answers, and train their own model on them. It turns a provider's expensive research into a cheap copy, and it usually breaks the provider's terms of service.
The best-known case was published by Anthropic on February 23, 2026. It said three AI labs, DeepSeek, Moonshot AI and MiniMax, had generated over 16 million exchanges with Claude through about 24,000 fraudulent accounts to extract its capabilities. Anthropic described distillation itself as "a widely used and legitimate training method", objecting to the unauthorised, large-scale use. Its defences included classifiers and behavioural fingerprinting to detect distillation patterns, stronger account verification, and sharing technical indicators with other labs and cloud providers.
Distillation attacks also matter for safety: a copied model may keep the teacher's skills without its safety training.
Benefits and Limits of Model Distillation
Benefits:
- Much lower inference cost and latency.
- Models small enough for phones, laptops and edge devices.
- Can keep most of the teacher's quality on a focused task.
- Private deployment on your own hardware.
Limits:
- The student is rarely better than the teacher and inherits its mistakes and biases.
- Quality drops on topics the training data didn't cover.
- Generating teacher data costs money, and logit distillation needs teacher access many providers don't give.
- Legal and licence limits on whose outputs you may train on.
FAQ
What is model distillation in simple terms?
Model distillation is training a small AI model to imitate a large one. The large teacher model produces answers or probabilities, and the small student model learns to reproduce them, so it gets much of the teacher's skill while being cheaper and faster to run.
Is knowledge distillation the same as model distillation?
Yes, the terms are used interchangeably. "Knowledge distillation" is the original research name from the 2015 Hinton paper; "model distillation" and "LLM distillation" are the more common names today.
Is model distillation legal?
Distilling your own models, or open models whose licences allow it, is legal and common. Distilling a commercial model through its API usually breaks its terms of service, which forbid using outputs to build competing models. Check the licence or terms of every teacher you use.
Does a distilled model perform as well as the original?
Usually not across the board, but it can come close on the specific task it was distilled for. DistilBERT, for example, kept 97% of BERT's language understanding while being 40% smaller, according to its authors.
What is the difference between distillation and fine-tuning?
Fine-tuning is the training method; distillation is a goal and a data source. In distillation the training targets come from a stronger teacher model, and the aim is to make a smaller model behave like it.