Machine Learning PapersLandmark papers
← All papers
RESEARCH PAPER / 2020

On Layer Normalization in the Transformer Architecture

Ruibin Xiong, Yunchang Yang, Di He ...Full author list in the original paper.

Chinese Academy of Sciences +4 · cs.LG

Affiliations: Chinese Academy of Sciences, University of Chinese Academy of Sciences, Peking University, Microsoft Research, Nankai University

Abstract

The Transformer is widely used in natural language processing tasks. To train a Transformer however, one usually needs a carefully designed learning rate warm-up stage, which is shown to be crucial to the final performance but will slow down the optimization and bring more hyper-parameter tunings. In this paper, we first study theoretically why the learning rate warm-up stage is essential and show that the location of layer normalization matters. Specifically, we prove with mean field theory that at initialization, for the original-designed Post-LN Transformer, which places the layer normalization between the residual blocks, the expected gradients of the parameters near the output layer are large. Therefore, using a large learning rate on those gradients makes the training unstable. The warm-up stage is practically helpful for avoiding this problem. On the other hand, our theory also shows that if the layer normalization is put inside the residual blocks (recently proposed as Pre-LN Transformer), the gradients are well-behaved at initialization. This motivates us to remove the warm-up stage for the training of Pre-LN Transformers. We show in our experiments that Pre-LN Transformers without the warm-up stage can reach comparable results with baselines while requiring significantly less training time and hyper-parameter tuning on a wide range of applications.

The following analysis is generated by AI and may contain errors. It is separate from the authors’ abstract and is not peer review.

Research summary

The main contribution of this paper is the theoretical and empirical demonstration that the learning rate warm-up stage can be safely removed for Pre-LN Transformers, leading to faster training without sacrificing performance. This work advances the understanding of optimization in Transformer architectures and provides practical guidance for model training in NLP tasks.

Methodology

The paper presents a theoretical analysis of the learning rate warm-up stage in Transformers, focusing on the positioning of layer normalization. The authors utilize mean field theory to derive insights into how gradient behavior at initialization varies between Post-LN and Pre-LN Transformers. This theoretical foundation is complemented by empirical experiments demonstrating the efficacy of training Pre-LN Transformers without a warm-up stage, significantly reducing training time and hyperparameter tuning.

Results & evaluation

The experiments are well-structured, covering multiple tasks including machine translation and unsupervised pre-training. The authors provide comprehensive results that validate their theoretical claims, showing that the Pre-LN Transformer can achieve comparable performance to the Post-LN Transformer while eliminating the warm-up stage. The use of standard benchmarks enhances the credibility of their findings.

Reproducibility

The paper includes sufficient details regarding experimental setups, hyperparameters, and datasets used, which would facilitate reproducibility. However, the absence of a public code repository limits full reproducibility.

Limitations

The paper does not explore the implications of the findings on other architectures beyond Transformers, nor does it address potential edge cases where the Pre-LN Transformer might underperform. Additionally, the theoretical analysis relies on certain assumptions that may not hold in all practical scenarios.

Broader impact

The findings have significant implications for practitioners in NLP, as they simplify the training process of Transformers, potentially leading to faster model development cycles. The ability to eliminate the warm-up stage could encourage broader adoption of Pre-LN Transformers in various applications. The main contribution of this paper is the theoretical and empirical demonstration that the learning rate warm-up stage can be safely removed for Pre-LN Transformers, leading to faster training without sacrificing performance. This work advances the understanding of optimization in Transformer architectures and provides practical guidance for model training in NLP tasks.

Curator note

Kitaev et al.; LSH attention; reduced quadratic complexity

Author of this paper? Send a correction.