How do label smoothing and knowledge distillation change cross-entropy training?
Written by the mlprep team · Updated
Explain label smoothing and knowledge distillation. Why can softer targets improve generalization, and what are the tradeoffs?
Label smoothing#
Standard cross-entropy uses one-hot labels: correct class probability 1, every other class 0. Label smoothing replaces that with a softened target:
correct class: 1 - epsilon
other classes: epsilon / (K - 1)
This discourages the model from becoming infinitely confident. It can improve generalization and reduce overfitting, especially when labels are noisy.
Tradeoff#
Label smoothing may hurt calibration in some settings because it intentionally trains the model away from true empirical probabilities. It can also hurt tasks where the model needs very sharp confidence for abstention or high-precision decisions.
Knowledge distillation#
Distillation trains a student model to match a teacher model's soft output distribution. Instead of only learning "cat is correct," the student learns that "dog" is more plausible than "truck." That structure is often called dark knowledge.
Temperature softens teacher probabilities:
softmax(logits / T)
Higher T reveals more relative similarity between non-top classes.
Why it helps#
Distillation can compress a large model into a smaller one, improve sample efficiency, and transfer behavior from an ensemble or foundation model. It is especially useful when the teacher is expensive but inference needs to be cheap.
Senior/staff considerations#
The key question is what behavior the soft labels encode. A teacher trained on biased data can transfer bias. A teacher with poor calibration can teach bad probabilities. A teacher that performs well on aggregate may fail on rare segments, and distillation may amplify that if the student has less capacity.
For production, evaluate the student on:
- original ground-truth labels
- teacher agreement
- segment-level performance
- calibration
- high-confidence error cases
- latency and cost reduction
Distillation is not only model compression. It can also create labels where human labels are expensive, but then label quality and policy review become central.
The key takeaway unlocks after you reveal an expert answer.
Key Takeaway
Label smoothing regularizes one-hot targets by reducing overconfidence. Distillation trains a student on a teacher's soft probabilities, transferring similarity structure and enabling cheaper serving. Both can improve generalization, but they can also hurt calibration or transfer teacher bias.
Follow-up Questions to Test Yourself
Interviewers often pivot here once you cover the core concept.
- Why does temperature help in distillation?
- When can label smoothing hurt calibration?
- How would you validate a distilled model before replacing a larger teacher in production?
How confident do you feel explaining this?
Track your understanding or flag it to revisit before your next loop.
Related Questions
What is focal loss and when would you use it over cross-entropy?
Explain cross-entropy loss — binary vs categorical, and why it works for classification
What is KL divergence and how does it relate to cross-entropy?
How would you design the click-through rate prediction system for an ads platform?