Transformers without Tears: Improving the Normalization of Self-Attention

Toan Q. Nguyen, Julian Salazar
10/14/2019
cs.CLcs.LGstat.ML

Official code: tnq177/transformers_without_tears (133 stars, MIT, PyTorch, last commit 2024-05-29).

Abstract

We evaluate three simple, normalization-centric changes to improve Transformer training. First, we show that pre-norm residual connections (PreNorm) and smaller initializations enable warmup-free, validation-based training with large learning rates. Second, we propose $\ell_2$ normalization with a single scale parameter (ScaleNorm) for faster training and better performance. Finally, we reaffirm the effectiveness of normalizing word embeddings to a fixed length (FixNorm). On five low-resource translation pairs from TED Talks-based corpora, these changes always converge, giving an average +1.1 BLEU over state-of-the-art bilingual baselines and a new 32.8 BLEU on IWSLT'15 English-Vietnamese. We observe sharper performance curves, more consistent gradient norms, and a linear relationship between activation scaling and decoder depth. Surprisingly, in the high-resource setting (WMT'14 English-German), ScaleNorm and FixNorm remain competitive but PreNorm degrades performance.

View on arXivView PDF

Code Implementations(1)

PyTorchMIT

Transformers without Tears: Improving the Normalization of Self-Attention

13317Perl, PythonOct 15, 20192 years agoMIT
attention-is-all-you-needmachine-translationpytorchtransformer

Similar Papers

Cite this paper

@article{nguyen2019transformers,
  title  = {Transformers without Tears: Improving the Normalization of Self-Attention},
  author = {Toan Q. Nguyen and Julian Salazar},
  year   = {2019},
  eprint = {1910.05895},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/1910.05895}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/1910.05895.svg)](https://codeofpaper.com/paper/1910.05895)

Discussion