Paper · 2021-05-27 · cs.LG, stat.ML
Towards Understanding Knowledge Distillation
Theory of distillation between linear classifiers, with soft labels and gradient flow. With n >= d the student recovers the teacher exactly. For n < d, a transfer-risk bound depends on the angle distribution, giving fast rates for margin and polynomial tasks. Author-reported experiments support data geometry, optimization bias and strong monotonicity.
Knowledge distillationImplicit bias of gradient descentdistillationlearning-theorylinear-modelsgradient-flow
AI-compiled by claude-haiku-5-5 on 2026-10-31, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.
In plain words
Knowledge distillation trains a small model not on the hard right-or-wrong answers, but on the probabilities another model assigns. This paper asks why that works, using the simplest possible setting: a straight-line rule as the teacher and a straight-line rule as the student.
In that setting the student can copy the teacher exactly once it has seen as many examples as there are input dimensions. With fewer examples, each new example moves the student closer to the teacher. How close it gets depends on how the data sits relative to the teacher's boundary: data that stays away from the boundary is easier. The training method itself also helps, because plain gradient descent from a near-zero start settles on a particularly good answer.
TL;DR
- Teacher and student are linear classifiers (a deep linear variant is also covered); the student is trained on the teacher's soft outputs §3.
- With at least
dexamples, the student's weight vector equals the teacher's and its transfer risk is zero [thm. 1] [thm. 3]. - With fewer examples, a bound on expected transfer risk depends on the angle distribution of the data; it gives exponential rates for angular-margin tasks and polynomial rates otherwise [thm. 3] [cor. 1] [cor. 2].
- Results are proven for linear models only; the conclusion treats the nonlinear case as open §6.
Problem
Distillation is widely used, but earlier explanations were qualitative §1. The paper asks what the student learns, how fast its risk falls with more transfer data, and which properties of the task and the training procedure matter §1. Standard learning-theory bounds for hard labels say little when the number of examples is below the dimension; the paper argues that distillation behaves differently in that regime §4.2.
Method
Setting §3
- Inputs
xinR^dare drawn i.i.d. from a densityP_x. The teacher is a fixed linear classifierh*(x) = 1{w*^T x >= 0}withw* != 0. - The transfer set holds
ninputs and soft labelsy_i = sigmoid(w*^T x_i). There are no hard labels and no label noise in the setup. - The student is
h(x) = 1{w^T x >= 0}, withw^T = W_N ... W_1.N = 1is a direct linear classifier;N >= 2is a deep linear network. - The student minimises the normalised cross-entropy against the soft labels.
A constant
L*makes the minimum zero; it does not change the optimum or the gradient §3 app. "Properties of the Cross-Entropy Loss". - Training is modelled as gradient flow, the limit of gradient descent with an
infinitesimal step size; the student is trained until
tau -> infinity§3. - The transfer risk is
R(h) = P_x[h(x) != h*(x)]§3.
Closed-form limit §4.1
- For
N = 1withw(0) = 0, the weight vector converges tow_hat, given by the formula below [thm. 1]. Its proof uses the fact that the gradient always lies in the span of the data, and strong convexity on that span app.. - For
N >= 2, zero initialisation is a stationary point, so the weights are initialised small but non-zero. Under three conditions (a norm bound on the initial weights, an initial loss below the loss at zero, and balancedness between layers) the end-to-end weight vector approachesw_hatforn >= d, and stays withinepsilonof it forn < d[thm. 2].
\hat w = \begin{cases} w^* & n \ge d \\ X (X^\top X)^{-1} X^\top w^* & n < d \end{cases} [thm. 1]
- For
n < d,w_hatis the orthogonal projection of the teacher onto the span of the training inputs. It is the closest point tow*that gradient descent can reach, since all updates stay in that span §4.1.
Transfer-risk bound §4.2
-
For a task,
p(theta)is the reverse CDF of the unsigned angle betweenw*and a random inputx§4.2:p(\theta) = P_x[\bar\alpha(w^*, x) \ge \theta], \quad \theta \in [0, \pi/2] §4.2
where
bar alpha(u, v) = arccos(|u^T v| / (|u| |v|))§4.2. -
Theorem 3: for
n >= dthe expected risk is zero. Forn < dand anybetain[0, pi/2]:\mathbb{E}[R(\hat h_X)] \le p(\beta) + p(\pi/2 - \beta)^n [thm. 3]
Proof idea: one training point on the far side of the angle cone already pulls the student's angle below
pi/2 - beta, and a random training set has such a point with high probability §4.3. -
Corollary 1 (angular margin): if some
betagivesp(beta) = 0andgamma = p(pi/2 - beta) < 1, then the expected risk is at mostgamma^n[cor. 1]. -
Corollary 2 (polynomial tail): if
p(theta) <= c (1 - (2/pi) theta)^kappafor alltheta, then the expected risk is at mostc (1 + (log n)^kappa) / n^kappa[cor. 2]. The corollary's proof setsbeta = (pi/2) n^(-1/n)[cor. 2].
Strong monotonicity §4.3
- Lemma (strong monotonicity): for nested full-rank training sets
X_- ⊆ X_+, the distillation solution forX_+has an angle tow*no larger than the one forX_-[lemma, §4.3]. Adding training data never hurts the closed-form student in this sense.
Extended result app., "Theorem 3 for Approximate Distillation"
- If the student's weight vector is within
epsilonofw_hat(withepsilon <= |w_hat| / 2), definedelta = sqrt(2 pi epsilon / |w_hat|). Then, forbetain[0, pi/2 - delta], the expected risk is at mostp(beta) + p(pi/2 - delta - beta)^napp.. Asepsilon -> 0,delta -> 0and the bound returns to Theorem 3.
Pseudocode of the closed form [thm. 1]
# Student for N = 1 with zero initialisation [§4.1] [thm. 1]
# Input: inputs (d, n) i.i.d. from P_x; teacher weights (d,)
# Output: student weights (d,)
def distilled_student(inputs, teacher_weights):
# Regime is decided by the number of examples [thm. 1]
num_dims, num_examples = inputs.shape
if num_examples >= num_dims:
# Enough data: the teacher is recovered exactly [thm. 1]
return teacher_weights
# Otherwise project the teacher onto the data span [thm. 1]
gram = inputs.T @ inputs # (n, n)
projector = inputs @ inverse(gram) @ inputs.T # (d, d)
return projector @ teacher_weightsPseudocode of the bound [thm. 3]
# Upper bound on expected transfer risk for n < d [§4.2] [thm. 3]
# Input: p, the reverse CDF of the teacher angle; n; beta in [0, pi/2]
# Output: scalar bound
def transfer_risk_bound(p, num_examples, beta):
# Points away from the boundary cut off large angles [thm. 3]
near_term = p(beta)
# Every training point must fall in the wrong cone for an error [§4.3]
far_term = p(pi / 2 - beta) ** num_examples
return near_term + far_termHyperparameters
Theory values are symbols; the experiment values are the ones stated in the text.
| Name | Value | Where | Notes |
|---|---|---|---|
Input dimension d (theory) | general | §3 | Inputs are in R^d; no bias term appears in the setup |
Student depth N | 1 or >= 2 | §3 §4.1 | Experiments do not state the depth used |
Initialisation, N = 1 | w(0) = 0 | [thm. 1] | |
Initialisation, N >= 2 | small, non-zero; norm below min{...} | [thm. 2] | Exact expression in [thm. 2] |
| Optimiser | gradient flow (infinitesimal step) | §3 | Finite step size is not analysed |
| Data-geometry experiment | d = 1000, n = 20 | §5.1 | Values of kappa used are not stated in the text; read from fig. 3 |
| Data-geometry task sampling | angle a with P[a >= theta] = (1 - (2/pi) theta)^kappa; direction uniform at that angle to w*; x = nu z, nu ~ N(0, 1) | §5.1 | Teacher w* choice not stated |
| Optimisation-bias experiment | d = 784 (MNIST pixels as vectors), n = 100 | §5.2 | Digits 0 and 1 only |
| Optimisation-bias learners | `w_delta = w_hat + delta ( | w_hat | / |
| Teacher for MNIST | logistic regression on an independent training set | §5.2 | |
| Monotonicity experiment | d = 100, n = 5, kappa = 1 | §5.3 | 1000 transfer sets averaged |
| Monotonicity learners | GD distillation, hard-target, and w_delta for delta in {1/16, 1/8, 1/4, 1/2, 1} | §5.3 | Hard-target learner's details not stated |
| Evaluation set size | not stated | §5.1 §5.2 | |
| Optimiser learning rate, step count, repetitions for §5.1 and §5.2 | not stated | §5 |
Results
Author-reported. Theory covers linear teachers and students with exact soft labels. Experiments are synthetic (§5.1, §5.3) and MNIST digits 0 vs 1 (§5.2), with linear learners only.
| Setting | Statement | Source |
|---|---|---|
Direct linear student, w(0) = 0, n >= d | converges to w* | [thm. 1] |
Direct linear student, n < d | converges to the projection of w* onto the data span | [thm. 1] |
Deep linear student, n >= d | converges to w* under the three initial conditions | [thm. 2] |
Deep linear student, n < d | stays within epsilon of the projection | [thm. 2] |
Transfer risk, n >= d | zero | [thm. 3] |
Transfer risk, n < d | p(beta) + p(pi/2 - beta)^n for any beta | [thm. 3] |
| Angular-margin tasks | <= gamma^n, with gamma < 1 | [cor. 1] |
| Polynomial tasks | <= c (1 + (log n)^kappa) / n^kappa | [cor. 2] |
| Data geometry (§5.1) | risk falls as kappa rises; plotted, no numbers in text | fig. 3 |
| Optimisation bias (§5.2) | risk is lower for learners closer to the gradient-descent solution (smaller delta) | fig. 4 |
| Strong monotonicity (§5.3) | negative correlation between monotonicity index and risk; no coefficient reported | fig. 5 |
The angular schematic (Tasks A, B, C) is fig. 1; the example margin and polynomial distributions are fig. 2. The paper gives no headline benchmark numbers, and no comparison with other methods.
Paper vs code
No official code.
Search done on the card's compile date:
- The arXiv metadata has no comments field and no project-page link. The LaTeX sources contain no URLs.
- GitHub repository search for
towards understanding knowledge distillationreturned only unrelated repositories (zihuixue/MFH,songmzhang/NMT-KD). - GitHub repository search for
linear distillationreturned no repository by these authors.postmachines/Linear-Distillation-Learning(MIT) is a third-party repository and is not used. - GitHub user search for
christoph lampert ist austriareturned no accounts matching either author. An IST Austria GitHub organisation was not searched.
Pitfalls
- Exact soft labels. The analysis assumes the labels are exactly the sigmoid of the teacher's logit, and the teacher is exactly linear. Noisy labels, nonlinear teachers and a bias term are outside the stated theory §3 §6.
- Gradient flow, not gradient descent. Every theorem is for the infinitesimal-step limit §3. The paper does not analyse finite step sizes.
- Deep-student initialisation. Theorem 2 needs a norm bound on the initial weights, an initial loss below the loss at zero, and balancedness [thm. 2]. The paper calls these practical, and notes that a sign flip can satisfy the loss condition §4.1. Balancedness is only approximated by near-zero initialisation; the paper cites evidence that approximate balancedness may suffice, without proving it §4.1.
- Corollary 2 in the statement and proof. The statement has a constant
cand no restriction ton < d. The displayed proof bound has noc, and the source does not reconcile the two [cor. 2]. Check the constant before using the rate. - Corollary 2 choice of
beta. The bound in Theorem 3 holds for anybeta. Making it explicit needs abetachosen from the task, here(pi/2) n^(-1/n)[cor. 2]. pis unknown in practice. Every rate needs the angle distributionp, which depends on the unknown teacher and the input distribution. The paper gives no way to estimate it from data §4.2.- Two loss normalisations. The main text uses one normalisation with a
constant
L*§3. The appendix uses per-example constants [app. "Properties of the Cross-Entropy Loss"]. The constants do not change the optimum or the gradient, so the closed form is the same under both. - Strong monotonicity is for the closed-form solution. The lemma is stated
for
w_hat(X), the distillation solution. For finite-step deep networks it is not established §4.3 §5.3. - Monotonicity is only correlational. The monotonicity index is binary and is measured, not manipulated; the paper says its effect on risk is unknown §5.3.
- Experiment details are missing. Learning rate, step count, held-out set
size, the
kappagrid, the teacher for §5.1, and the depth used in §5.2 and §5.3 are not stated. The results are qualitative trends read from plots. - Not claimed for nonlinear models. The conclusion states that the nonlinear case is a hypothesis and the main direction for future work §6.
Lineage
- Builds on: Hinton, Vinyals and Dean (2014) for distillation itself §1 (no arXiv id in the paper's bibliography, so no card link).
- Deep linear networks as a model: Saxe et al. (2014), Kawaguchi (2016), Hardt and Ma (2017) §3.
- Balancedness and gradient-flow analysis of deep linear networks: Arora, Cohen and Hazan (2018) and Arora, Cohen, Golowich and Hu (2019) §4.1.
- Earlier theory: Urner et al. (2011), who view distillation as a semi-supervised method §2. Other theory on learning from privileged information and teaching sets is discussed in §2.
- Compared against: hard-label learning, where standard bounds need
n >> d§4.2 and the paper's strong-monotonicity property does not hold §4.3. - Superseded by: not known from content on this wiki.
Source and license
Adapted from “Towards Understanding Knowledge Distillation” by Mary Phuong, Christoph H. Lampert (arXiv:2105.13093), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors.