On Layer Normalization in the Transformer Architecture
arXiv:2002.04745
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.
Cited by in corpus (46)
- CogView: Mastering Text-to-Image Generation via Transformers
- Do Transformers Really Perform Bad for Graph Representation?
- PanGu-: Large-scale Autoregressive Pretrained Chinese Language Models with Auto-parallel Computation
- BASE Layers: Simplifying Training of Large, Sparse Models
- Choose a Transformer: Fourier or Galerkin
- Long-Short Transformer: Efficient Transformers for Language and Vision
- Normalization Techniques in Training DNNs: Methodology, Analysis and Application
- Luna: Linear Unified Nested Attention
- Scalable and Efficient MoE Training for Multitask Multilingual Models
- The Lipschitz Constant of Self-Attention
- Egocentric Human Trajectory Forecasting with a Wearable Camera and Multi-Modal Fusion
- RealFormer: Transformer Likes Residual Attention
- Scaling Laws for Neural Machine Translation
- M6-10T: A Sharing-Delinking Paradigm for Efficient Multi-Trillion Parameter Pretraining
- A Lorentz-Equivariant Transformer for All of the LHC
- PipeTransformer: Automated Elastic Pipelining for Distributed Training of Transformers
- SpecTNT: a Time-Frequency Transformer for Music Audio
- Searching for Efficient Multi-Stage Vision Transformers
- Global Rhythm Style Transfer Without Text Transcriptions
- GradInit: Learning to Initialize Neural Networks for Stable and Efficient Training
- An Efficient Transformer Decoder with Compressed Sub-layers
- Many-to-Many Voice Transformer Network
- Large-Scale Deep Learning Optimizations: A Comprehensive Survey
- UniSpeech at scale: An Empirical Study of Pre-training Method on Large-Scale Speech Recognition Dataset
- Can Vision Transformers Perform Convolution?
- Grounded Situation Recognition with Transformers
- The Piano Inpainting Application
- A Loss Curvature Perspective on Training Instability in Deep Learning
- Robust Optimization for Multilingual Translation with Imbalanced Data
- Temporal Pyramid Transformer with Multimodal Interaction for Video Question Answering
- 1-bit LAMB: Communication Efficient Large-Scale Large-Batch Training with LAMB's Convergence Speed
- Transforming jet flavour tagging at ATLAS
- Speeding up Deep Model Training by Sharing Weights and Then Unsharing
- GroupBERT: Enhanced Transformer Architecture with Efficient Grouped Structures
- Towards Deeper Deep Reinforcement Learning with Spectral Normalization
- An Interpretable Framework for Drug-Target Interaction with Gated Cross Attention
- Federated Learning with Dynamic Transformer for Text to Speech
- Self-Attentive Ensemble Transformer: Representing Ensemble Interactions in Neural Networks for Earth System Models
- NVIDIA NeMo Neural Machine Translation Systems for English-German and English-Russian News and Biomedical Tasks at WMT21
- Learning Pessimism for Robust and Efficient Off-Policy Reinforcement Learning
- Serialized Multi-Layer Multi-Head Attention for Neural Speaker Embedding
- How could Neural Networks understand Programs?
- Multilingual Translation via Grafting Pre-trained Language Models
- Competence-based Curriculum Learning for Multilingual Machine Translation
- Type Anywhere You Want: An Introduction to Invisible Mobile Keyboard
- The Brownian motion in the transformer model