The interview problem
You have a strong three-class teacher and a smaller student intended for a low-latency service. Choose a training objective using teacher logits and verified labels. Calculate one example, explain temperature scaling and design an experiment that distinguishes useful compression from copying the teacher's mistakes.
Original fundamentals practice, not a reported company interview. Numerical examples and deployment scenario are hypothetical. Primary paper published March 9, 2015; retrieved September 27, 2026. Interview date: not applicable.
1. Specify exactly what the student matches
Let pT = softmax(v/T) for frozen teacher logits v, and qT = softmax(z/T) for student logits z. One objective is L = (1 − α) CE(y, q1) + α T² KL(pT || qT), with 0 ≤ α ≤ 1 and T > 0. Use the same class order and temperature for the soft-target comparison. The label loss uses temperature one. Teacher probabilities are detached from student optimization.
Teacher-to-student KL and soft-target cross entropy have the same student gradient when the teacher is fixed: they differ by teacher entropy. Higher temperature softens targets. The T² multiplier approximately balances gradient scale as temperature changes; it does not make objectives identical. The exact unscaled logit gradient is (qT − pT)/T. At high temperature, their difference is also approximately proportional to 1/T. Ordinary inference uses temperature one unless separately calibrated.
2. Calculate a complete example
Choose teacher logits [2, 0, −2], student logits [1, 0, −1], label class A, T = 2 and α = 0.5. All logarithms below are natural logarithms. At temperature two, teacher probabilities are approximately [0.665241, 0.244728, 0.090031]; student probabilities are [0.506480, 0.307196, 0.186324]. Both predict A, but agreement on the top class does not make their distributions equal.
KL is the sum of pᵢ log(pᵢ/qᵢ), giving approximately 0.060269. Student probabilities at temperature one are [0.665241, 0.244728, 0.090031], so the label loss is −log(0.665241) = 0.407606. The mixed objective is 0.5 × 0.407606 + 0.5 × 4 × 0.060269 = 0.324341.
Do not compare teacher probabilities at temperature two with student probabilities at temperature one just because they happen to coincide in this example. That would incorrectly produce zero matching loss. Do not assume this mixed loss can be compared directly across different temperatures or weights to select the best model; changing those settings changes the objective scale and meaning. Compare held-out task outcomes.
For class A, the scaled soft-loss gradient before multiplying by α is 2 × (0.506480 − 0.665241) = −0.317521. The hard-label gradient is 0.665241 − 1 = −0.334759. Their equal-weight sum is −0.326140. A negative gradient here pushes the A logit upward under gradient descent, consistent with both targets wanting more A probability.
3. Show what happens when the teacher is wrong
At temperature one, suppose the teacher assigns [0.9, 0.1] but the verified label is B. With α = 0.8, combining the two cross-entropy gradients is equivalent to training toward [0.72, 0.28]. An unconstrained student optimizing only this one-example objective would still predict A. With α = 0.2, the combined target becomes [0.18, 0.82], which predicts B. This target-mixture interpretation applies here because both losses use temperature one; it is not a general shortcut for the earlier mixed-temperature objective.
A correct training pipeline therefore still can transfer systematic teacher errors. Check label reliability, inspect disagreement slices and choose the teacher weight using validation data. Filtering to teacher-correct examples changes the training distribution and may discard precisely the hard cases the student needs. Retain a measured hard-case evaluation set rather than hiding these cases from the report.
4. Build a reproducible training path
versioned transfer inputs → frozen teacher → cached targets
↓ ↓
verified labels + split IDs → student training → validation
↓
held-out quality + serving benchmarkRecord teacher checkpoint, preprocessing, class mapping, target format, transfer-data version and label provenance. Split by the relevant entity or time boundary before augmentation and target generation. Generating teacher outputs on the training partition does not authorize using test examples for student training. Keep final evaluation untouched by teacher-weight and temperature selection. Audit teacher training overlap with the evaluation set where provenance is available: a clean student split cannot undo answers memorized by a contaminated teacher. If teacher provenance is unknown, record that limitation and add newly collected, independently labeled evaluation cases.
Cache logits when storage permits flexibility in later temperature choices. Ten million examples with 1,000 float32 class logits require 40 billion bytes, or 40 GB of raw logits, before identifiers, replicas or file overhead. Saving only top classes reduces storage but loses the omitted probability mass. Renormalizing a truncated distribution changes the objective; record that approximation explicitly.
For unlabeled transfer examples, omit the hard-label term and define separate averaging and weighting for labeled and unlabeled populations. Otherwise a change in their proportions can silently change the effective objective. For sequence models, mask padding and document whether loss averages over tokens or sequences. Token-level matching also requires aligned output vocabularies and positions; this classification example does not solve cross-tokenizer alignment.
5. Separate agreement, accuracy and serving benefit
On a hypothetical 1,000-example held-out set, let teacher and student both be correct on 850 examples, only the teacher correct on 80, only the student correct on 40, and both wrong on 30. Teacher accuracy is 93%; student accuracy is 89%. Among the 30 both-wrong examples, suppose they choose the same wrong class on 20 and different wrong classes on 10. Their prediction agreement is then (850 + 20)/1,000 = 87%. Agreement is a distinct measure from either model's accuracy.
Compare the distilled student against a student trained only on labels under an explicit training-data and compute budget. Also report teacher performance, class-specific errors, calibration and shifted-data behavior. A student can outperform its teacher on some cases without being better overall. Use paired uncertainty estimates for differences and select acceptance thresholds before viewing final results.
Suppose teacher latency is 100 ms and student latency 20 ms under the same hardware, batch size and workload. That is a measured 5× latency ratio in this scenario, not a universal throughput or cost claim. A model with fewer parameters can still be slower under a different kernel or serving setup. Benchmark memory, throughput and tail latency alongside quality.
6. Failure analysis, follow-ups and self-review
Common failures include permuted class columns, stale targets after preprocessing changes, gradients updating the teacher, a missing temperature multiplier, unstable logarithms, and reductions that average over classes rather than summing class contributions per example. Use stable log-softmax calculations and verify a tiny example against the hand calculation above.
Follow-ups: Is a hard teacher label equivalent to a soft distribution? No; it discards alternatives. Does distillation require reducing weight precision? No; quantization is a separate compression choice. Can an API exposing only generated text support this exact KL objective? Not without the required aligned probability information. Must the student be smaller? No, but the deployment objective here asks for a smaller, faster model. Does teacher confidence prove label correctness? No.
Score 0–2 each for objective definition, numerical calculation, teacher-error handling, reproducible data boundaries and honest quality/latency evaluation. A strong answer can explain why the student has a nonzero soft loss despite matching the teacher's top prediction.
Sources and next steps
- Hinton, Vinyals and Dean: Distilling the Knowledge in a Neural Network — foundational soft-target objective and temperature-gradient reasoning.
The worked values, error table, storage estimate and deployment experiment are original. Continue with quantization to distinguish learning a smaller model from changing numerical precision.
Continue your preparation
Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.