Need help with Transformer-Clinic?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

168 Stars 10 Forks Apache License 2.0 42 Commits 0 Opened issues


Understanding the Difficulty of Training Transformers

Services available


Need anything else?

Contributors list

# 31,120
38 commits

License PWC


Understanding the Difficulty of Training Transformers

With systematic analyses, we simplify and automate Transformer training. Admin successfully stabilizes previously-diverged model training and achieves better performance, without introducing additional hyper-parameters.

We are in an early-release beta. Expect some adventures and rough edges.

Table of Contents


What complicates Transformer training?

In our study, we go beyond gradient vanishing and identify an amplification effect that substantially influences Transformer training. Specifically, for each layer in a multi-layer Transformer, heavy dependency on its residual branch makes training unstable, yet light dependency leads to sub-optimal performance.

Dependency and Amplification Effect

Our analysis starts from the observation that Pre-LN is more robust than Post-LN, whereas Post-LN typically leads to a better performance. As shown in Figure 1, we find these two variants have different layer dependency patterns.

With further exploration, we find that for a N-layer residual network, after updating its parameters W to W*, its outputs change is proportion to the dependency on residual branches.

Intuitively, since a larger output change indicates a more unsmooth loss surface, the large dependency complicates training. Moreover, we propose Admin (adaptive model initialization), which starts the training from the area with a smoother surface. More details can be found in our paper.

Quick Start Guide

Our implementation is based on the fairseq package (

python 3.6, torch 1.5/1.6
are recommended). It can be installed by:
git clone
cd fairseq
pip install --editable .
The guidance for reproducing our results is available at: - WMT'14 De-En - WMT'14 De-Fr - IWSLT'14 En-De

Specifically, our implementation requires to first set

--init-type adaptive-profiling
and use one GPU for this profiling stage, then set
--init-type adaptive
and start training.


Please cite the following papers if you found our model useful. Thanks!

Liyuan Liu, Xiaodong Liu, Jianfeng Gao, Weizhu Chen, and Jiawei Han (2020). Understanding the Difficulty of Training Transformers. Proc. 2020 Conf. on Empirical Methods in Natural Language Processing (EMNLP'20).

  title={Understanding the Difficulty of Training Transformers},
  author = {Liu, Liyuan and Liu, Xiaodong and Gao, Jianfeng and Chen, Weizhu and Han, Jiawei},
  booktitle = {Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP 2020)},
Xiaodong Liu, Kevin Duh, Liyuan Liu, and Jianfeng Gao (2020). Very Deep Transformers for Neural Machine Translation. arXiv preprint arXiv:2008.07772 (2020).
 author = {Liu, Xiaodong and Duh, Kevin and Liu, Liyuan and Gao, Jianfeng},
 booktitle = {arXiv:2008.07772 [cs]},
 title = {Very Deep Transformers for Neural Machine Translation},
 year = {2020}

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.