ArticleslgStudy

science

Knowledge distillation

Knowledge distillation is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Knowledge distillation rather than just read about it. In short: In machine learning, knowledge distillation or model distillation is the process of transferring knowledge from a large model to a smaller one. While large models (such as very deep neural networks or ensembles of many models ) have more knowledge capacity than small models, this capacity might not be fully utilized.

Key takeaways

  • Knowledge distillation belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Knowledge distillation to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Knowledge distillation from memory before moving on to harder problems.

Reference excerpt

In machine learning, knowledge distillation or model distillation is the process of transferring knowledge from a large model to a smaller one. While large models (such as very deep neural networks or ensembles of many models ) have more knowledge capacity than small models, this capacity might not be fully utilized. It can be just as computationally expensive to evaluate a model even if it utilizes little of its knowledge capacity. Knowledge distillation transfers knowledge from a large model to a smaller one without loss of validity. As smaller models are less expensive to evaluate, they can be deployed on less powerful hardware (such as a mobile device). There is also a less common technique called Reverse Knowledge Distillation, where knowledge is transferred from a smaller model to a larger one. Model distillation is not to be confused with model compression, which describes methods to decrease the size of a large model itself, without training a new model. Model compression generally preserves the architecture and the nominal parameter count of the model, while decreasing the bits-per-parameter. Knowledge distillation has been successfully used in several applications of machine learning such as object detection, acoustic models, and natural language processing. Recently, it has also been introduced to graph neural networks applicable to non-grid data.

Methods Knowledge transfer from a large model to a small one somehow needs to teach the latter without loss of validity. If both models are trained on the same data, the smaller model may have insufficient capacity to learn a concise knowledge representation compared to the large model. However, some information about a concise knowledge representation is encoded in the pseudolikelihoods assigned to its output: when a model correctly predicts a class, it assigns a large value to the output variable corresponding to such class, and smaller values to the other output variables. The distribution of values among the outputs for a record provides information on how the large model represents knowledge. Therefore, the goal of economical deployment of a valid model can be achieved by training only the large model on the data, exploiting its better ability to learn concise knowledge representations, and then distilling such knowledge into the smaller model, by training it to learn the soft output of the large model.

Mathematical formulation Given a large model as a function of the vector variable x {\displaystyle \mathbf {x} } , trained for a specific classification task, typically the final layer of classification networks is a softmax in the form

y i ( x | t ) = e z i ( x ) t ∑ j e z j ( x ) t {\displaystyle y_{i}(\mathbf {x} |t)={\frac {e^{\frac {z_{i}(\mathbf {x} )}{t}}}{\sum _{j}e^{\frac {z_{j}(\mathbf {x} )}{t}}}}}

where t {\displaystyle t} is the temperature, a parameter which is set to 1 for a standard softmax. The softmax operator converts the logit values z i ( x ) {\displaystyle z_{i}(\mathbf {x} )} to pseudo-probabilities: higher temperature values generate softer distributions of pseudo-probabilities among the output classes. Knowledge distillation consists of training a smaller network, called the distilled model, on a data set called the transfer set which could correspond to the original training set or consist of new, possibly unlabeled data. A cross-entropy loss function is typically used, computed between the output of the distilled model y ( x | t ) {\displaystyle \mathbf {y} (\mathbf {x} |t)} and the output of the large model y ^ ( x | t ) {\displaystyle {\hat {\mathbf {y} }}(\mathbf {x} |t)} on the same record (or the average of the individual outputs, if the large model is an ensemble), using a high value of softmax temperature t {\displaystyle t} for both models:

E ( x | t ) = − ∑ i y ^ i ( x | t ) log ⁡ y i ( x | t ) . {\displaystyle E(\mathbf {x} |t)=-\sum _{i}{\hat {y}}_{i}(\mathbf {x} |t)\log y_{i}(\mathbf {x} |t).}

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Knowledge distillation

Start with the simplest possible case. Write down what Knowledge distillation claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Knowledge distillation before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Knowledge distillation ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Knowledge distillation

In research
Knowledge distillation appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Knowledge distillation in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Knowledge distillation is common in secondary-school and first-year university syllabi. It links to neighbouring topics Deep learning, so understanding it makes those chapters shorter.
In everyday life
Look for Knowledge distillation outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Knowledge distillation” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Knowledge distillation in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Knowledge distillation means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Knowledge distillation out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Knowledge distillation in simple terms?

In machine learning, knowledge distillation or model distillation is the process of transferring knowledge from a large model to a smaller one. While large models (such as very deep neural networks or ensembles of many models ) have more knowledge capacity than small models, this capacity might not…

Why does Knowledge distillation matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Knowledge distillation?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Knowledge distillation.

Tags

  • Deep learning

Keep exploring