Understanding the Difficulty of Training Transformers

Liyuan Liu, Xiaodong Liu, Jianfeng Gao, Weizhu Chen, Jiawei Han
4/17/2020
332 citations
cs.LGcs.CLstat.ML
transformer-attention

Official code: LiyuanLucasLiu/Transformer-Clinic (331 stars, Python, Apache-2.0, last commit 2022-05-31).

Abstract

Transformers have proved effective in many NLP tasks. However, their training requires non-trivial efforts regarding designing cutting-edge optimizers and learning rate schedulers carefully (e.g., conventional SGD fails to train Transformers effectively).

Show full abstract

Our objective here is to understand $\textit{what complicates Transformer training}$ from both empirical and theoretical perspectives. Our analysis reveals that unbalanced gradients are not the root cause of the instability of training. Instead, we identify an amplification effect that influences training substantially -- for each layer in a multi-layer Transformer model, heavy dependency on its residual branch makes training unstable, since it amplifies small parameter perturbations (e.g., parameter updates) and results in significant disturbances in the model output. Yet we observe that a light dependency limits the model potential and leads to inferior trained models. Inspired by our analysis, we propose Admin ($\textbf{Ad}$aptive $\textbf{m}$odel $\textbf{in}$itialization) to stabilize stabilize the early stage's training and unleash its full potential in the late stage. Extensive experiments show that Admin is more stable, converges faster, and leads to better performance. Implementations are released at: https://github.com/LiyuanLucasLiu/Transforemr-Clinic.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Understanding the Difficulty of Training Transformers

33121Python, ShellApr 1, 20204 years agoApache-2.0
initializationnmttransformerwmt

Similar Papers

Cite this paper

@article{liu2020understanding,
  title  = {Understanding the Difficulty of Training Transformers},
  author = {Liyuan Liu and Xiaodong Liu and Jianfeng Gao and Weizhu Chen and Jiawei Han},
  year   = {2020},
  eprint = {2004.08249},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2004.08249}
}

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/2004.08249.svg)](https://codeofpaper.com/paper/2004.08249)

Discussion