Model Distillation
A large model performs excellently but is too heavy for a phone or too expensive for production. Distillation transfers its knowledge into a smaller model — like a summary instead of a full textbook.
Idea: Teacher and Student
Distillation is the training of a small model (the 'student') on the answers of a large (the 'teacher') model. The student does not memorize correct answers but learns to emulate the behavior of the teacher.
flowchart LR
A[Large model-teacher] -->|generates responses| B[Dataset]
B --> C[Training of small model]
C --> D[Student with part of teacher's knowledge]
The teacher does not have to be perfect — it is important that they are stronger than the student and demonstrate how to reason and respond in a certain style.
Why It Works
The teacher model outputs not only answers but also 'soft' probabilities: even incorrect options receive scores reflecting their proximity to the correct answer. The student adopts this distribution rather than just the correct labels.
Thus, the small model absorbs nuances: 'this answer is almost correct', 'this formulation is better than that'. Traditional training on hard labels does not convey such information.
What is Usually Distilled
- Reasoning. The large model shows chains of thought, the student learns to reason similarly.
- Style and format. The student adopts the tone and structure of the responses.
- Narrow skills. For example, one task — excellent, not everything at once.
A classic example is DeepSeek-R1-Distill models: the knowledge of a large reasoning model is transferred into smaller versions based on Qwen and Llama.
Pros and Cons
| Pros | Cons |
|---|---|
| Smaller model is cheaper | Student cannot surpass teacher |
| Faster on weak hardware | Requires access to the teacher |
| Can be run locally | Quality is limited by the teacher's ceiling |
How It Differs from Other Compression Methods
- Quantization — the same model, but numbers are shorter. Quality is almost the same, speed is higher.
- Pruning — unnecessary parts are cut out of the model. The model is the same but smaller.
- Distillation — another, smaller model that learns from a large one. The architecture may differ.
What It Looks Like in Practice
Simplified process:
- Take a large model-teacher.
- Run a set of queries through it and collect responses.
- Train a small model on these responses.
- Evaluate the student: is it close enough to the teacher?
For language models, this is an iterative process: often the student is further trained on a mix of teacher data and regular datasets to avoid losing basic skills.
When Distillation is a Good Choice
- Need a small and fast model on a device;
- Have a strong model that is expensive to run in production;
- Speed and cost are more important than maximum quality.
If quality is critical, it is better to leave the large model and save on quantization.
In Brief
Distillation is the transfer of knowledge from a large model to a small one through its responses. The student is faster and cheaper but not smarter than the teacher. This is one of three compression tools alongside quantization and pruning.
