Label smoothing

When the model learns that “dog” is “Hund”, the plain target says: probability 1 for Hund, 0 for every other word. Label smoothing asks for a little less certainty: it keeps most of the target on the right word and spreads a small share ε over the whole vocabulary.

The training target

  1. Hund 91.7 %
  2. Katze 1.7 %
  3. Vogel 1.7 %
  4. Pferd 1.7 %
  5. Ball 1.7 %
  6. Buch 1.7 %

The loss of three predictions

Predictionp(Hund)Loss, smoothed targetLoss, plain target
Sure and right97.4 %0.4770.027
Unsure30.9 %1.2481.175
Sure and wrong0.2 %5.8776.027
Exactly the smoothed target91.7 %0.4210.087

The three predictions are made up to show the idea; the losses are computed from them. The last row is the prediction that matches the smoothed target exactly: the lowest loss training can reach.

Our model, trained with and without it

Our modelHeld-out lossPerplexityFirst step at 95 %
With label smoothing (ε_ls = 0.1)0.06321.0652187 (180–200)
Without label smoothing0.00051.0005200 (180–220)

Without smoothing, the held-out loss falls almost to 0: the model is nearly certain of every right word. With smoothing it stays near 0.06, because the model was trained never to be quite sure. Yet both first translate 95 % of held-out sentences at about the same step, and both translate them right. A worse loss, the same translations: that is the paper's point.

Why make a model less sure?

With a plain target, the model can always lower its loss by being even more certain, pushing its scores further apart. That habit makes it overconfident about wrong words too, and it learns little about which other words were nearly right. With a smoothed target, being too certain costs loss, so the model keeps some probability for close alternatives, which tends to help the beam search and the final translation.

Perplexity is e to the power of the loss: roughly how many words the model is hesitating between. Smoothing raises it on purpose, so it is a poor guide to a smoothed model's quality; BLEU, which scores the translations themselves, is the better one.

In the paper (5.4)

“During training, we employed label smoothing of value ε_ls = 0.1. This hurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score.”

An unhandled error has occurred. Reload 🗙

Reconnecting…

Your connection to the Transformers and Attention Lab dropped, probably a Wi-Fi blip. Hold on while it reconnects.

The connection could not be restored. The page will reload in a few seconds.