DL0181 Label Smoothing and Model Calibration

What is Label Smoothing, and how does it affect model calibration, overconfidence, and the trade-off between accuracy and log-likelihood?

Answer

Label smoothing replaces the one-hot target with a mixture of the one-hot vector and the uniform distribution, so the true class receives 1-\epsilon+\epsilon/K and every other class receives \epsilon/K. Written this way it is exactly standard cross-entropy plus an \epsilon-weighted KL term pulling the prediction toward uniform, which gives the loss a finite minimizer instead of one that is reached only as the true-class probability approaches 1. That single change removes the pressure that makes logit gaps grow without bound after the argmax is already correct, so the model stops becoming more confident with more training and the classic overconfidence of modern networks largely disappears. The consequences are asymmetric: Expected Calibration Error (ECE) usually drops sharply and top-1 accuracy is flat or slightly better, but the hard-label negative log-likelihood gets worse, because a converged smoothed model deliberately withholds probability mass from the correct class. The Transformer paper states this trade-off explicitly, using \epsilon=0.1 and noting that it hurts perplexity while improving accuracy and BLEU.

(1) Target Mixing: the label becomes (1-\epsilon)y+\epsilon/K, which is equivalent to cross-entropy plus \epsilon\,\mathrm{KL}(u\,\|\,p) up to an additive constant.
(2) Bounded Logit Gap: the optimum sits at a finite logit difference, roughly 9.1 nats for \epsilon=0.1 and K=1000, so logit norms stop inflating.
(3) Confidence Ceiling: a well-fit smoothed model cannot report top-class confidence above 1-\epsilon+\epsilon/K, which is 0.900 at \epsilon=0.1.
(4) Calibration Improves, Then Overshoots: ECE is U-shaped in \epsilon, moving the model from overconfident through calibrated to systematically underconfident.
(5) Log-Likelihood Penalty: the confidence ceiling implies a hard-label NLL floor of -\log(1-\epsilon+\epsilon/K), about 0.105 nats per example at \epsilon=0.1.
(6) Information Erasure: smoothing equalizes the wrong-class logits, which tightens penultimate-layer clusters and damages knowledge distillation and feature transfer.

Reliability diagram plotting bin accuracy against mean predicted confidence for three training settings: hard labels sit below the perfect-calibration diagonal indicating overconfidence, label smoothing with epsilon 0.1 tracks the diagonal closely and stops at confidence 0.900, and label smoothing with epsilon 0.3 sits above the diagonal indicating underconfidence and stops at confidence 0.700

Figure 1: Reliability curves for the same architecture under three targets. Hard labels fall below the diagonal (confidence exceeds accuracy), \epsilon=0.1 tracks the diagonal, and \epsilon=0.3 lands above it. Note the truncated horizontal extent: each smoothed curve stops at its confidence ceiling 1-\epsilon+\epsilon/K, 0.900 and 0.700 for K=1000. Curves are illustrative of published trends rather than a single benchmark run.

The mechanism is easiest to read off the gradient with respect to the true-class logit, which is p_y-1 under hard labels and p_y-(1-\epsilon+\epsilon/K) under smoothing. The hard-label gradient is strictly negative for every finite logit, so optimization keeps pushing the correct logit away from the others long after the prediction is right, and confidence keeps drifting upward while accuracy has already plateaued. The smoothed gradient changes sign once the model reaches the target probability, which pins confidence and caps the logit gap. The wrong-class gradients change too: each incorrect logit is pulled toward the same small target \epsilon/K, so the model is discouraged from expressing that “husky” is much closer to “wolf” than to “airliner”. That equalization is exactly the property Müller and colleagues identified as the reason a label-smoothed teacher makes a worse distillation teacher than a hard-label teacher of identical accuracy.

Mathematical Formulation:
y^{\mathrm{LS}}_k = (1-\epsilon)\,y_k + \epsilon/K
\mathcal{L}_{\mathrm{LS}} = -\sum_{k=1}^{K} y^{\mathrm{LS}}_k \log p_k
\mathcal{L}_{\mathrm{LS}} = (1-\epsilon)\mathcal{L}_{\mathrm{CE}} + \epsilon\,\mathrm{KL}(u\,\|\,p) + c
p^{\star}_{y} = 1 - \epsilon + \epsilon/K
z_y - z_j = \log\left(\frac{K(1-\epsilon)+\epsilon}{\epsilon}\right)
\mathrm{ECE} = \sum_{m=1}^{M} \frac{|B_m|}{N}\left|\mathrm{acc}(B_m) - \mathrm{conf}(B_m)\right|

Where:

  • y \in \{0,1\}^{K} is the one-hot label and y^{\mathrm{LS}} the smoothed target over K classes.
  • \epsilon \in [0,1) is the smoothing strength, \epsilon=0 recovering ordinary cross-entropy; 0.1 is the near-universal default.
  • p_k = \mathrm{softmax}(z)_k is the predicted probability, z the logits, y the index of the correct class and j any incorrect class.
  • u_k = 1/K is the uniform distribution, and c = \epsilon H(u) is a constant independent of the parameters, which is why the objective is cross-entropy plus a uniform-KL penalty.
  • p^{\star}_{y} is the per-example minimizer, giving the finite logit gap in the fifth line; the gap grows only logarithmically as \epsilon shrinks.
  • B_m is the set of the N validation examples whose top confidence falls in bin m of M (typically M=15), and ECE is the confidence-weighted gap plotted in Figure 1.

Log-Likelihood Floor At \epsilon=0.1, K=1000:
p^{\star}_{y} = 0.9 + 0.0001 = 0.9001
-\log(0.9001) = 0.1052
\exp(0.1052) = 1.111

The third line is the practical reading for sequence models: a converged smoothed model pays roughly 11% higher perplexity than its own hard-label counterpart would at the same accuracy, purely from the withheld mass, which is why translation systems that smooth at training time are usually evaluated with BLEU or COMET rather than perplexity. Note also that this floor is a property of the optimum, not a hard constraint on the network: a single global temperature fitted on held-out data can sharpen the smoothed logits back and recover most of the lost likelihood. That observation is the reason smoothing is not the right tool if calibrated probabilities are the goal, since post-hoc temperature scaling reaches comparable ECE at zero training cost, one scalar parameter, and no distortion of the wrong-class ranking.

Three side-by-side line charts against smoothing strength epsilon from 0 to 0.4: hard-label negative log-likelihood dips slightly then rises while an analytic floor curve rises monotonically, expected calibration error forms a U shape with a minimum near epsilon 0.1, and top-1 accuracy stays on a flat plateau before declining past epsilon 0.2

Figure 2: The three metrics disagree about the best \epsilon. ECE is U-shaped with a minimum near 0.05 to 0.1, hard-label NLL dips only briefly before the analytic floor -\log(1-\epsilon+\epsilon/K) dominates, and accuracy is flat across a broad plateau. Choosing \epsilon therefore means choosing which metric you are optimizing. Values are illustrative of published sweeps.

PropertyLabel smoothingTemperature scalingConfidence penalty / focal loss
When appliedTraining time, changes the targetsPost-hoc, one scalar fitted on a held-out splitTraining time, changes the loss on the prediction side
Effect on accuracyFlat to slightly better; degrades past roughly 0.2Exactly zero, the argmax is invariant to a positive temperatureTask dependent; focal loss helps mainly under heavy class imbalance
Effect on hard-label NLLWorse at convergence, floored at -\log(1-\epsilon+\epsilon/K)Directly minimized by the fitting objective, so it improvesUsually worse, for the same mass-withholding reason
Logit ranking preservedNo, wrong-class logits are equalizedYes, it is a monotone rescaling of all logitsPartially, the entropy term flattens the tail
Main failure modeUnderconfidence at large \epsilon; weaker distillation teacher and weaker transfer featuresOne global scalar cannot fix per-class or per-slice miscalibration, and it needs a clean validation splitExtra hyperparameter with little calibration gain over a fitted temperature

Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *