Knowledge Distillation

Training a smaller model to imitate a larger one so it becomes cheaper to deploy.

What can a small model learn from a large model’s hesitation?

A teacher model sorts archive images into etching, drawing and photograph. These illustrative distributions use the same three categories in the same order.

Clear example

For one scan the teacher assigns 90%, 8% and 2%. It strongly favors etching.

Ambiguous example

For another the teacher assigns 48%, 47% and 5%. Etching still ranks first, but drawing is almost tied.

What the student can inherit

A student trained only on the winning class would receive “etching” twice. Distillation can use a fuller output distribution, often adjusted with a temperature parameter, to communicate relative preferences. Test the smaller model against independent labels and measure its latency on the intended device. The student can inherit a teacher’s mistakes.

What the Student Learns

The student model may learn from soft targets rather than only final labels. Those soft targets contain information about relative confidence across many possible answers, which can encode structure that ordinary supervised labels do not capture. In generative systems, distillation can also train a smaller model to imitate the style or response behavior of a larger assistant.

The result is rarely a perfect copy. A smaller model usually gives up some capability. But if the trade-off is chosen well, the student can deliver most of the value at a fraction of the cost.

Follow the idea

Model compression includes other ways to reduce model size or cost.

Fine-tuning can further adapt a trained model to the archive’s collection.

Source · Hinton, Vinyals and Dean on knowledge distillation

Return to Knowledge Distillation in the A–Z glossary