On Layer Normalization in the Transformer Architecture

By Ruibin Xiong, Yunchang Yang, Di He, Shuxin Zheng, Chen Xing, Huishuai Zhang, Yanyan Lan, Liwei Wang, Tie-Yan Liu. 2020

1,522 citations recorded by the source corpus.

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 hyperparameter 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.

Subfields: Electrical and Electronic Engineering, Electronic, Optical and Magnetic Materials, Model Architectures

How researchers see this paper

The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.

In Electrical and Electronic Engineering

  1. Shuhao Cao
  2. Tim Dettmers
  3. Luke S. Zettlemoyer
  4. Yu Qiao
  5. George Papamakarios
  6. Jianfeng Gao
  7. Tengyu Ma
  8. Matthew Botvinick

In Electronic, Optical and Magnetic Materials

  1. Shuhao Cao
  2. Quoc V. Le
  3. Tie-Yan Liu
  4. Yi Tay
  5. David R. So
  6. Quentin Fournier
  7. Daniel J. Aloise
  8. Gaétan Marceau Caron

In Model Architectures

  1. Jianfeng Gao
  2. Quoc V. Le
  3. Xipeng Qiu
  4. Yi Tay
  5. Mostafa Dehghani
  6. Tie-Yan Liu
  7. Furu Wei
  8. Caiming Xiong

Citations in the corpus