Skip to content
mentoor

Topic 1 of 5 · 4 min read

Teacher and student models

Goal: Explain what a student model learns from its teacher and predict the kinds of task where it will fall short.

Distillation trains a small student model to imitate a large teacher model, so you pay for the teacher once, at training time, and run the cheap student on every request.

Check yourself · 1 of 3

What does a student model in distillation learn from the teacher?

Choose one answer

Why it matters

A large model such as Claude, GPT or Gemini can handle almost any request, but it costs more and answers slower than a 1B to 8B open-weight model. If your product sends the same kind of request a million times a day, most of that capability goes unused. Distillation moves the part you need into a model you can host yourself, or call at a lower price.

What the student learns

The student does not copy the teacher's weights. It copies behaviour. The teacher answers a large set of prompts, and the student is trained to produce the same answers. Two kinds of signal are used:

  • Hard targets: the teacher's final text. The student learns "for this input, write this output."
  • Soft targets: the teacher's probability for every possible next token. This carries more information. If the teacher gives 70% to "Paris" and 20% to "Lyon", the student also learns that Lyon was a close second. Geoffrey Hinton called this extra signal "dark knowledge"; the 2015 paper by Hinton and colleagues showed how to train a student on it.

How to do it

  1. Pick one narrow task, for example "classify a support ticket into 12 categories and extract the order id."
  2. Collect thousands of realistic prompts for that task.
  3. Run the teacher on them and keep its outputs, or its token probabilities if you can read them.
  4. Train a small base model on those pairs.
  5. Test on held-out prompts the teacher has never seen with the student.

Before and after

Weak plan: "Distill GPT into a 3B model so it is as smart as GPT." Nobody can say what done means, and the student has far less capacity than the teacher. Better plan: "Distill the ticket classifier. Target: within 2 points of the teacher's accuracy on our 500-ticket test set, at a tenth of the cost." The task is narrow, the goal is measurable.

What goes wrong

  • The student inherits the teacher's mistakes. It learns what the teacher does, not what is true. If the teacher mislabels a category 8% of the time, the student copies that.
  • The student is only good where the teacher data was. Prompts unlike the training set, such as a new language or a long document, fall off fast.
  • Capacity gaps show up on hard tasks. Multi-step maths, rare facts and long-context reasoning need parameters a small model does not have. Narrow classification and formatting survive distillation well; broad knowledge does not. DistilBERT shows the typical trade: a smaller, faster model that keeps most, not all, of the original's quality.
  • Teacher noise. Without filtering, a hallucinated teacher answer becomes a training label.

Examples

Ticket triage

A shop sends 40,000 support tickets a day through a large model that returns a category and an order id. The team runs the teacher on 20,000 past tickets, keeps the outputs, and trains a small open-weight student on them. On 500 held-out tickets the student matches the teacher on category and misses the order id on a few odd formats. The task is narrow, so the student is a good fit.

Where the student breaks

The same student is asked to answer free-form questions about return law in three countries. It was never shown that material and has too few parameters to store it, so it answers fluently and wrongly. Fluent output is not evidence of copied skill.

Key points

  • A student model imitates the teacher's behaviour on a task; it does not receive the teacher's weights or knowledge in general.
  • Soft targets (token probabilities) carry more information per example than the teacher's final text alone.
  • Distillation works best on narrow, high-volume tasks with a measurable target, not on 'be as smart as the teacher'.
  • The student inherits the teacher's errors and is weak on inputs unlike its training prompts.
  • Tasks needing broad knowledge, rare facts or long multi-step reasoning are where a small student falls short first.

Common mistakes

  • Expecting the student to match the teacher across all tasks instead of the one it was trained on.
  • Training on unfiltered teacher outputs, so teacher hallucinations become labels.
  • Testing the student on the same prompts it was trained on.
  • Treating soft targets and hard targets as the same thing when the teacher's probabilities are available.

Check yourself · 2 of 3

A team wants a cheap model for one job: extracting invoice totals from emails, 2 million a month. Which goal is best suited to distillation?

Choose one answer

Check yourself · 3 of 3

The teacher gives 70% to 'Paris' and 20% to 'Lyon' for the next token. Why does a student trained on those probabilities learn more than one trained on 'Paris' alone?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic