← the late compiler
C_000206 · llms and generative ai · advanced

Knowledge Distillation

Training a small student model to reproduce a large teacher's outputs, transferring capability into a cheaper package.

Step 1 of 4

In words

What it is, why it matters, and what it is like.

Why am I learning this?

Knowledge distillation is the standard way to turn a huge, expensive model into a small, fast one that fits on your phone or laptop. After this page, you'll understand what happens when you hear that a company 'distilled' their largest model into a smaller one — and you'll be ready for the next concepts in this path: Quantization (making models smaller by using fewer bits per number) and Model Deployment (actually getting a model running on your own hardware). Distillation is also the reason many small 'open' models exist that run locally — they are usually distilled from giants.

The idea, in plain terms

Imagine you are a new chef trying to learn how to make a perfect biryani. You've never cooked it before. You could read a recipe — that's like a dataset with labels: 'add 2 cups of rice', 'cook for 30 minutes'. But a recipe only tells you the steps, not the feel — the aroma, the color, the exact moment the rice is done. Now imagine instead you stand next to a master chef who shows you their finished dish and tells you, 'This is what perfection looks like — aim for this.' You taste it, you see it, you smell it. You might learn faster and better than reading a recipe because you're not just copying steps, you're matching a richer target.

In machine learning, a 'teacher' model is the master chef — big, slow, but incredibly skilled. It has seen millions of examples and learned complex patterns. When you train a model normally, you show it an image (say, a cat) and you tell it, 'The answer is "cat"'. That's a hard label — like a recipe. But the teacher model, when shown the same image, doesn't just say 'cat'. It also says, 'I'm 98% sure it's a cat, 1.5% dog, 0.5% bird.' That soft distribution contains so much more information — it tells the student not just *what* the answer is, but *what other answers were close*. A cat picture that looks a bit like a dog teaches the student, 'These two are similar.' Hard labels never say that.

So knowledge distillation is simply: instead of teaching the student with the original data and hard labels, we teach it with the teacher's soft outputs. The student tries to mimic those outputs, and by doing so, it absorbs the teacher's 'wisdom' — the relationships between classes, the subtle patterns — without needing to be as big or slow as the teacher.

An analogy

The master craftsman and the apprentice. A master carpenter can build a beautiful chair, but she is slow and expensive, and she uses a huge workshop. The apprentice wants to learn to build the same chair, but quickly and with just a few hand tools.

If the apprentice just reads a list of measurements — 'the leg is 40 cm long, the seat is 50 cm wide' — she might make a chair that looks roughly right, but it will lack the subtle curves, the perfect balance, the feel of quality. The measurements are the hard labels: correct but limited.

So instead, the master sits the apprentice down and says, 'Watch me. I'm going to build a chair, but I'm also going to narrate my decisions: "I'm using this wood because it flexes slightly; I'm rounding this edge because it feels better in the hand; I'm using a dovetail joint here because it's stronger than a nail."' The apprentice doesn't just see what the master does — she hears the *why* behind the choices. This is the soft output: a rich description of the craft, not just the final product.

The apprentice then practices by trying to make chairs that would get the same praise from the master. Every time she makes a chair, she compares it to what the master would have made — not just the measurement, but the whole feel. Over time, the apprentice becomes nearly as good as the master, but she works with a much smaller set of tools and much less time.

Where the analogy breaks down: In our analogy, the apprentice learns *why* from the master's words. In real distillation, the student never hears any 'why'. It only sees the teacher's output probabilities — soft numbers — and tries to get its own output numbers to match. It doesn't understand the reasoning; it just learns to produce the same result. Also, the apprentice gets *better* than the master over time (she might have her own style), but a distilled student is capped at the teacher's quality — it can only be as good as what it imitates.

Definition

Knowledge distillation is a training method where a small student model learns to imitate the output probabilities of a large teacher model, thereby transferring the teacher's learned knowledge into a more compact and efficient model.

Where this sits

You're starting this path with no prerequisites, which is fine. This concept sits at the heart of inference optimization — the art of making models cheaper and faster to run. In your library, you have notes on 'Quantization' (representing numbers with fewer bits) and 'Local Model Deployment' (running models on your own hardware). Distillation is a key reason those are possible: a distilled model is often small enough that quantisation alone isn't enough, but distillation shrinks the model first. The three often work together: first distill, then quantise, then deploy locally. Also, you have notes on 'Edge and Air-Gapped Inference' — distillation is critical there because devices have hard memory limits. This page is your first step into that world.

Signal from the Frontier

Get the next essay on mind, machine, and meaning

Essays at the intersection of AI, philosophy, and Indian governance. No promotional content.

We'll send a one-click sign-in link to confirm. No password needed.

Views expressed are personal and do not represent the Government of India or the Government of Uttarakhand.