4.3.14 · D3Pretraining & Fine-Tuning LLMs

Worked examples — Knowledge distillation

2,315 words11 min readBack to topic

Everything here builds on three tools from the parent, restated in plain words so no symbol is unearned:


The scenario matrix

Every distillation calculation lives in one of these cells. The examples below are labelled with the cell they cover.

# Case class What's special Example
A Baseline normal softmax, no softening Ex 1
B Warming soft targets surface (positive & negative logits) Ex 2
C Limit distribution uniform Ex 3
D Limit distribution one-hot (argmax) Ex 3
E Degenerate teacher — all logits equal zero dark knowledge to transfer Ex 4
F Full loss, teacher-agrees + , both point same way Ex 5
G Full loss, teacher-disagrees teacher's argmax true label Ex 6
H extremes pure hard / pure soft training Ex 7
I The audit show gradient shrinks without Ex 8
J Word problem (LLM vocab) huge , next-token distribution Ex 9
K Exam twist — negative-logit shift invariance trap: does adding a constant change ? Ex 10

Case A & B — softening across signs

Figure — Knowledge distillation

Look at the s01 figure: the burnt-orange bars () are spiky; the teal bars () are flattened — same order, softer spread.


Cases C & D — the two limits

Figure — Knowledge distillation

The s02 figure shows three panels — cold (, spike), warm (), hot (, flat) — the whole temperature spectrum on one strip.


Case E — the degenerate teacher


Cases F & G — the full combined loss

Recall the parent's distillation loss (with the mixture weight defined above): where (teacher vs student , both at temperature ) and . See Cross-Entropy and KL Divergence for why cross-entropy is the right "distance."


Case H — the extremes


Case I — the audit


Case J — the LLM word problem


Case K — the exam twist


Recall Matrix coverage self-test

Which cell hides the biggest real-world danger for LLM distillation? ::: Cell J — a huge uniform "background" of low-logit tokens; over-warming ( too large) lets those tokens collectively steal almost all probability mass, destroying the useful signal, so real LLM KD uses moderate or top- logits. Why is Cell E (equal logits) untrainable? ::: The teacher's distribution is uniform for every , carrying zero relational dark knowledge. Which cell proves you must keep the factor? ::: Cell I — the soft gradient collapses as rises (about weaker at here, trending toward ); the prefactor restores it. What does correspond to? ::: Pure hard-label training with no teacher signal — ordinary supervised learning.


Connections