chapter seven

7 Knowledge distillation: Capturing frontier model intelligence

 

This chapter covers

  • Building a black-box distillation pipeline from teacher data generation through student training
  • Filtering teacher outputs to remove degenerate or low-quality responses
  • Evaluating distillation quality with three-way comparisons (base, teacher, student)
  • Understanding when forward vs. reverse Kullback-Leibler (KL) divergence matters
  • Testing whether safety alignment transfers from teacher to student (it does not)

Your chapter 6 SFT model answers IT support questions well, but the frontier API you tested during project scoping (GPT-6 Astra, Claude Opus 5, or Gemini 3.1 Pro) answers them better. The catch: that API costs $5,000 per month at your current query volume, and every request sends proprietary data off-network. What if you could capture 80 to 90% of the frontier model’s quality in a smaller, locally run model at a fraction of the cost?

Continuing the chapter 5 example, picture distilling that Contoso support assistant rather than a generic model. The question isn't only whether the student maintains overall accuracy, but whether it still preserves the house answer format and domain behavior, because those specifics are the easiest to lose when you compress a model. As before, the hands-on uses the reproducible IT support data, while the lesson applies to any internal assistant you have already specialized in.

7.1 Hands-on: The distillation recipe

7.1.1 Stage 1: Task identification and prompt design

7.1.2 Stage 2: Teacher data generation

7.1.3 Stage 3: Quality verification

7.1.4 Stage 4: Student training

7.1.5 Student inference

7.1.6 Testing the quality filter

7.2 Evaluating distillation quality

7.2.1 Three-way comparison

7.2.2 Interpreting the results

7.2.3 Beyond Token-F1: Using an LLM judge for distillation quality

7.2.4 Scaling behavior

7.2.5 Error analysis

7.3 Why distillation matters

7.3.1 What distillation can and cannot do

7.4 Distillation intuition

7.4.1 The teacher-student framework

7.4.2 Distillation vs. fine-tuning on the same data

7.4.3 What the student actually learns

7.4.4 White-box vs. black-box distillation

7.4.5 The DeepSeek-R1 distillation results

7.5 Reverse KL divergence for selective knowledge transfer

7.5.1 Forward vs. reverse KL