跪拜 Guibai
← Back to the summary

LLM Distillation, Explained: What Teacher Models Hand Down, What Students Learn, and Where It Fails

What Exactly Is Being Distilled in LLM Distillation? One Article to Understand the Concept of Knowledge Distillation

Recently I've seen the term "large model distillation" a lot, especially when discussing LLM training costs, inference capabilities, and technical gaps between different models. Distillation has almost become an unavoidable concept.

But many people, like me at first, have quite a few questions about distillation.

Don't LLMs just output text? Why can using that text to train another model improve its capabilities? Is distillation replicating knowledge, or learning reasoning ability? Why can some models with very small parameter counts solve quite complex problems?

Today let's talk about knowledge distillation. No complex math formulas, and even without a machine learning background you can follow.

1. What is knowledge distillation?

Knowledge Distillation (KD) is a training technique that transfers knowledge from one model to another.

In 2015, Geoffrey Hinton, Oriol Vinyals, and Jeff Dean published the classic paper "Distilling the Knowledge in a Neural Network," which systematically introduced the knowledge distillation training method.

Understanding distillation isn't actually difficult.

image.png

Imagine an experienced math teacher who has studied a lot of mathematical knowledge, solved countless problems, and accumulated much problem-solving experience. Now there's a student who already has some basic knowledge but is still relatively weak at solving complex problems.

The student can read many books on their own, keep doing problems, keep trial and error, or can directly learn from this teacher.

The teacher organizes representative problems, answers, problem-solving methods, and areas where mistakes are easily made, and the student improves their abilities by learning this content.

Knowledge distillation uses similar thinking.

In the AI field, the model that provides knowledge is called the Teacher Model, and the model being trained is called the Student Model.

              Teacher Model
                    │
                    ▼
        Provides knowledge and training signals
                    │
         ┌──────────┼──────────┐
         │          │          │
      Answers  Probability  Reasoning
                distribution  explanations
         │          │          │
         └──────────┼──────────┘
                    ▼
            Train student model
                    │
                    ▼
             Student Model

Traditional knowledge distillation was mainly used for model compression, letting small models gain some capabilities of large models, thus reducing running costs.

In the large language model era, distillation's uses are no longer limited to model compression. They also include knowledge transfer, reasoning ability improvement, specialized domain training, and capability fusion between different models.

The teacher model doesn't have to be larger than the student model, and the student model doesn't have to learn from only one teacher.

2. How do LLMs actually learn?

To understand distillation, you first need to understand how LLMs are trained.

When LLMs generate content, they predict the next Token based on existing context. A Token can be simply understood as the basic processing unit of text; it can be a character, a word, or part of a word.

For example, we input to the model:

Earth's only natural satellite is...

The model predicts what might come next.

Suppose a poorly trained model gives the following probabilities:

Candidate Predicted probability
Moon 40%
Mars 25%
Sun 20%
Other 15%

Clearly, although the model thinks the Moon is most likely the correct answer, its prediction isn't accurate enough.

The training system calculates the gap between the model's prediction and the target based on the correct training target. This gap can be measured as a numerical value, which we call Loss.

Next, through backpropagation and an optimizer, the model's internal parameters are adjusted so predictions gradually get closer to the training target.

After sufficient training, the model's predictions might become:

Candidate Predicted probability
Moon 97%
Mars 1%
Sun 1%
Other 1%

The probabilities above are for explaining the principle only, not real model output.

The whole training process can be simplified as:

Input training data
      ↓
Model makes predictions
      ↓
Compute prediction error
      ↓
Adjust model parameters
      ↓
Train again

This process repeats many times, and the model gradually learns language patterns, knowledge, and problem-solving methods.

The difference with knowledge distillation: besides traditional training data, we can also have an already-trained model provide learning targets.

3. Traditional knowledge distillation: not just learning the correct answer

Suppose we're training an image recognition model to recognize a photo of a husky.

Traditional supervised learning tells the model that the correct category for this photo is dog.

image.png

This kind of training label that only provides a clear category is called a Hard Label.

But if we let a very capable teacher model recognize this photo, it might give probabilities for different categories:

image.png

This set of data is called a Soft Label.

Looking closely at these two sets of data, you can see that soft labels provide richer information.

Hard labels only tell us the husky is a dog, and all other answers are wrong. Soft labels also reflect that the teacher model considers the husky similar to a wolf, and less similar to a cat.

This information hidden in prediction probabilities is often called Dark Knowledge in the knowledge distillation field.

If the student model can learn this information, it has a chance to gain part of the classification rules the teacher model has mastered.

How does the student model learn?

Suppose the teacher and student both recognize the same photo:

Animal Teacher model Student model
Dog 85% 40%
Wolf 12% 20%
Fox 2.5% 30%
Cat 0.5% 10%

It's clear the student model's judgments differ significantly from the teacher's across categories.

In one common distillation training method, the student needs to do two things at once: get as close to the true answer as possible, and get as close to the teacher model's prediction distribution as possible.

The former gap is called Hard Loss, and the latter gap is called Soft Loss.

The training system adjusts the student model's parameters based on both gaps.

Animal Teacher model Student before distillation After distillation (illustrative)
Dog 85% 40% 82%
Wolf 12% 20% 14%
Fox 2.5% 30% 3%
Cat 0.5% 10% 1%

This is the core idea of traditional knowledge distillation: let the student learn not only the correct answer, but also the teacher's judgments about different answers.

As for concepts like Softmax, Temperature, and KL divergence that often appear in distillation papers, they are mainly used to generate appropriate probability distributions, measure gaps between distributions, and control the training process.

You don't need to master these mathematical details to understand the basic principles of distillation.

4. Distillation in the LLM era

What's described above is traditional probability distribution distillation.

But the LLM era introduced a problem: many commercial models don't open their model weights, nor do they provide complete prediction probabilities. Developers can usually only get text, code, or other structured content generated by the model through APIs.

Can distillation still be done in this case?

Yes.

As long as you have the corresponding data usage rights, you can train a student model using content generated by the teacher model. This approach doesn't require access to the teacher model's internal parameters.

4.1 Answer distillation

Suppose we want to train a model good at math. We can prepare a large number of math problems first, then have the teacher model generate answers.

For example:

{
    "question": "A pool has 100 liters of water, 5 liters flow out every minute, how long until it's empty?",
    "answer": "20 minutes"
}

Collect large numbers of similar QA pairs and train the student model on them.

The student model gradually builds connections between questions and answers by learning these QA pairs.

This method usually falls under Sequence-level Distillation.

But it has an obvious problem: knowing the correct answer doesn't necessarily mean mastering the problem-solving method.

Like a student who memorizes the answers to a hundred math problems, if the exam changes the problem, they still might not solve it.

This leads to reasoning distillation.

4.2 Reasoning distillation

Unlike only learning answers, reasoning distillation tries to make the student model learn the problem-solving process provided by the teacher model.

Using the same problem, we can change the training data to:

image.png

Comparing the two sets of training data:

Learned content Answer distillation Reasoning distillation
Problem description Yes Yes
Correct answer Yes Yes
Condition analysis No Yes
Problem-solving method No Yes
Intermediate calculation steps No Yes

Reasoning distillation provides richer learning material. The student model learns not only the answer, but also how to analyze problems, break them down, and organize solution steps.

In 2023, Google published a study called "Distilling Step-by-Step!" which used natural language reasoning explanations generated by LLMs to help smaller models learn specific tasks.

Experiments showed that, on the tasks evaluated in the paper, this approach improved training data utilization efficiency and improved small model performance.

Note that a model's outputted reasoning explanation doesn't necessarily equal its real internal computation process. So reasoning distillation transfers the problem-solving behavior demonstrated by the teacher, not a direct copy of the teacher model's internal thinking mechanisms.

5. Why does learning text improve reasoning?

This is the most worth-understanding question in the whole knowledge distillation process.

Suppose we have a student model learn the following four problems:

Problem Solution method Answer
100 liters of water, 5 liters outflow per minute 100 ÷ 5 20 minutes
120 km, driving 60 km per hour 120 ÷ 60 2 hours
300 yuan, spending 30 yuan per day 300 ÷ 30 10 days
500 pages, reading 50 pages per day 500 ÷ 50 10 days

These four problems involve a pool, a car, money, and reading; they look like completely different problems, but the underlying computation pattern is the same.

All of them divide the total by the change per unit time to find the time required.

Now give the student model a problem it has never seen:

A factory needs to produce 2400 parts, and can produce 120 per hour. How many hours are needed?

If the model only memorized previous answers, it likely can't solve this new problem.

If the model learned the underlying pattern during training, it can calculate the correct answer: 20 hours.

This ability to apply learned patterns to unknown problems is called Generalization.

Of course, real LLMs are far more complex than this example. Neural networks don't necessarily store an explicit mathematical formula internally; instead they represent and learn relationships between inputs and outputs through vast numbers of parameters.

This also explains why the quality of training data matters so much.

If a teacher model generates a million highly repetitive problems, the student might only memorize fixed patterns. But if training data includes different problem types, different ways of expression, and correct reasoning examples, the student has a better chance of gaining capabilities that transfer to new problems.

Distillation isn't simply piling up data and Tokens.

6. What does a complete distillation process look like?

Suppose we want to cultivate a model good at math reasoning. The whole distillation process can be roughly divided into six stages.

Step 1: Choose teacher model and student model

The teacher model needs strong capability on the target task.

The student model is usually an already-pretrained base model, because it already has basic language understanding, knowledge, and content generation abilities.

There's no need to have the student learn all knowledge from scratch.

Step 2: Prepare training problems

Collect or generate a large number of representative problems.

If the goal is improving math ability, training problems need to cover basic computation, algebra, geometry, probability, logical reasoning, and other types, rather than repeatedly training the same kind of problem.

Step 3: Generate training data

Have the teacher model answer these problems and generate answers and solution examples.

As needed, the teacher can generate multiple solution methods for the same problem, then filter out the higher-quality results.

Step 4: Data cleaning

Teacher models make mistakes too, so you can't directly use all generated content for training.

Data needs deduplication, error checking, answer verification, format normalization, and quality filtering.

For math problems, verification can be done programmatically; for coding problems, generated code can be checked by compiling and running test cases.

Data quality directly affects the final distillation result.

Step 5: Train the student model

Use the filtered data to perform Supervised Fine-Tuning (SFT) on the student model.

In this phase, the training system continuously updates the student model's parameters so its generated content is closer to the training target.

The teacher model usually stays unchanged.

Step 6: Model evaluation

After training, test the student model on problems not used in training.

What needs to be verified isn't just answer accuracy; also reasoning performance, generalization, running speed, GPU memory usage, and output stability.

Full flow:

Choose teacher model
      ↓
Prepare training problems
      ↓
Generate answers and reasoning data
      ↓
Clean, deduplicate, verify
      ↓
Choose student model
      ↓
Supervised fine-tuning SFT
      ↓
Independent test evaluation
      ↓
Deploy student model

After distillation completes, the abilities the student model has learned live in its own model parameters, so it doesn't need to call the teacher model every time it answers.

This is an important difference between knowledge distillation and directly calling a third-party API.

7. Real case: DeepSeek-R1 distilled models

In 2025, DeepSeek released the R1 reasoning model and, at the same time, six distilled models.

Distilled model Base model Parameters
R1-Distill-Qwen-1.5B Qwen 1.5B
R1-Distill-Qwen-7B Qwen 7B
R1-Distill-Llama-8B Llama 8B
R1-Distill-Qwen-14B Qwen 14B
R1-Distill-Qwen-32B Qwen 32B
R1-Distill-Llama-70B Llama 70B

According to DeepSeek's official technical documentation, these models were fine-tuned from existing Qwen and Llama base models using about 800K curated training samples. The training samples include reasoning and non-reasoning tasks.

                DeepSeek-R1
                 Teacher model
                       │
                       ▼
        Generate and filter training data
                       │
                       ▼
              About 800K samples
                       │
       ┌───────────┴───────────┐
       ▼                       ▼
   Qwen base models        Llama base models
       │                       │
       ▼                       ▼
     Fine-tune               Fine-tune
       │                       │
       ▼                       ▼
  Qwen distilled          Llama distilled
  models                   models

There's a very important detail here: DeepSeek didn't directly compress R1's weights into six smaller models. Instead, they used curated training data to train other existing base models.

These student models already had some language understanding and knowledge capabilities; by further learning the training data R1 provided, they improved their reasoning performance.

This also shows that teacher and student models can use different model architectures and still achieve knowledge transfer through appropriate training methods.

For ordinary users, the biggest value of distilled models is lowering the hardware barrier to using reasoning models. Part of the capabilities of a full model that originally required lots of GPU memory can be obtained through a much smaller student model.

8. Why does distillation accelerate model development?

Training a capable base model requires massive data, compute, funding, and R&D personnel, and involves many experiments and failures.

Knowledge distillation can use the high-quality training signals provided by already-trained models, letting student models reduce some of the cost of repeated exploration.

The difference between the two approaches is roughly:

Comparison Training from scratch Distillation based on existing models
Starting point A model without basic capabilities yet A model usually already with basic capabilities
Data source Large amounts of raw data Teacher-generated data or other training signals
Learning target Build basic knowledge and general capabilities Acquire or improve specific capabilities
Compute investment Usually high Depends on model scale and training goals
R&D cycle Usually long Chance to be shorter
Independent exploration Requires many experiments Can leverage the teacher's existing results

Of course, distillation doesn't mean no R&D cost.

Choosing a base model, generating training problems, filtering data, designing training methods, and controlling model quality still require corresponding algorithm and engineering capabilities.

If you just collect large numbers of teacher model answers, train the student on them without filtering, the final result may not be ideal, and could even degrade the original model's capabilities.

9. Can distilled models surpass teacher models?

Yes, but usually with a specific task and evaluation conditions.

For example, a general teacher model needs to master literature, history, programming, math, medicine, and lots of other knowledge, while a student model only needs to focus on math reasoning.

The student model can further improve its ability in this domain through large amounts of high-quality math training data.

So a smaller student model outperforming a general teacher model on certain math tests is not impossible.

Additionally, student models can combine knowledge from multiple teacher models.

Math teacher ──┐
Programming teacher ──┤
Logic teacher ──┼──→ Data filtering and training ──→ Student model
Domain-specific data ──┘

Combined with its own training data and reinforcement learning, a student can achieve better results on specific tasks.

However, beating a teacher on one benchmark doesn't mean comprehensively beating the teacher. Knowledge coverage, complex-task performance, stability, and generalization all need to be evaluated separately.

10. What's the difference between distillation, fine-tuning, quantization, and RAG?

These concepts often appear together in LLM articles, but they solve different problems.

Technique Simple understanding
Pre-training Building the model's basic knowledge and language ability
Fine-tuning Having an existing model further learn specific abilities
Distillation Having a model learn knowledge provided by another model
Reinforcement Learning (RL) Adjusting model behavior based on reward signals
Quantization Lowering the precision of model parameter representation to reduce running resources
RAG Looking up external knowledge when answering questions
Prompt Guiding the model to use existing abilities through prompting

The easiest to confuse are distillation and fine-tuning.

Fine-tuning is a training method; distillation describes a process of knowledge transfer.

If you train a base model with manually-written specialized data, that's fine-tuning.

If you train a student model using data generated by a teacher model, then the process can belong to both fine-tuning and knowledge distillation.

The difference between RAG and distillation is more obvious.

RAG is like looking up reference materials during an exam; distillation is like gaining knowledge through study before the exam.

RAG usually doesn't require modifying model parameters, while distillation typically requires training to change the student model's parameters.

11. Limitations of knowledge distillation

Although knowledge distillation can reduce some training costs, it isn't a silver bullet.

First, teacher models aren't always right. If training data contains wrong knowledge and wrong reasoning processes, the student model may also learn these errors.

Second, the student model's parameter scale, architecture, and base capabilities all affect what knowledge it can ultimately gain. You can't expect a very small model to fully possess all the capabilities of a top model through simple distillation.

There's another easily overlooked problem: a model may learn the teacher's expression style without actually gaining the corresponding problem-solving ability.

For example, a model can generate reasoning processes that look very professional, but the final answer is still wrong. It may also perform well on the problem types it was trained on, but once the problem description changes, accuracy drops noticeably.

So evaluating distillation results can't just look at whether the model's answers resemble the teacher's; you should observe whether it can independently solve new problems.

Additionally, using third-party models for distillation requires considering model licenses, API service agreements, and training data usage rights.

Knowledge distillation itself is a normal technology, but being technically feasible doesn't mean all data acquisition methods are authorized.

Final thoughts

After understanding knowledge distillation, reading various LLM technical reports becomes less mysterious.

From early learning of teacher models' probability distributions, to later learning teacher-generated answers, code, and reasoning explanations, researchers have been trying to solve the same problem: how to make an already-trained model provide more effective learning signals for another model.

Distillation's biggest value is letting student models avoid fully repeating the learning and exploration process the teacher went through, while still having a chance to gain part of its capabilities.

But how much can ultimately be learned depends on the base model, training data, training methods, and evaluation system.

Distillation is not simply copying another model; it's using training to let one model gain part of another model's knowledge and capabilities.


References

The probability distributions and pre/post-training comparison data in this article are for illustration only, not real model experiment results.

Comments

Top 3 from juejin.cn, machine-translated. The original thread is authoritative.

HelloWorker

Like

约洛

Distillation is giving the answer first, then providing the reasoning process itself.

去吧波波鸟

Very thorough explanation. The husky example of hidden knowledge in soft labels made it click instantly. RAG is like looking up materials during an exam, and distillation is studying before the exam. I'm taking that analogy to use directly.