Papers › On Layer Normalization in the Transformer Architecture

On Layer Normalization in the Transformer Architecture

12 Feb 2020ICML 2020 1arXiv:2002.04745archive 2025-07-28

Ruibin Xiong, Yunchang Yang, Di He, Kai Zheng, Shuxin Zheng, Chen Xing, Huishuai Zhang, Yanyan Lan, Li-Wei Wang, Tie-Yan Liu

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.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2002.04745")

Code

Syntology Ran 2 of 11 code samples harvested from 1 repository linked to this paper; 9 have no recorded run. Of those that ran: 2 ran · honoured contract.

By repository: community (archive-listed): 11 samples from 1 repository, 2 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

airi-institute/gena_lm mentioned on GitHubpytorch report
blues-lin/fin-analyze mentioned on GitHubtf report
colorfulscoop/tfdlg mentioned on GitHubtfMIT report
davidsvy/cosformer-pytorch mentioned on GitHubpytorchMIT report
facebookresearch/xformers mentioned on GitHubpytorch report
noriyukipy/tfchat mentioned on GitHubtfMIT report
noriyukipy/tfdlg mentioned on GitHubtf report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

11 samples harvested; 2 ran; 2 honoured the contract we drafted; 9 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

2ran · honoured contract
9unverified

Licence: 0 of the 11 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from colorfulscoop/tfdlg. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

filter_to_topp colorfulscoop/tfdlg/tfdlg/generations.py community (archive-listed) ran · honoured contract fingerprinted MIT (permissive) · f10aa6a3b19fd64e · report
gelu colorfulscoop/tfdlg/tfdlg/activations.py community (archive-listed) ran · honoured contract fingerprinted MIT (permissive) · d7b9cc73b75d3829 · report
create_look_ahead_mask colorfulscoop/tfdlg/tfdlg/models.py community (archive-listed) unverified MIT (permissive) · 868953286060f3a8 · report
create_padding_mask colorfulscoop/tfdlg/tfdlg/models.py community (archive-listed) unverified MIT (permissive) · fd2b714b8c2af39e · report
encode_dialog colorfulscoop/tfdlg/tfdlg/dialog/tokenizers.py community (archive-listed) unverified MIT (permissive) · 22942e09fd44078d · report
filter_bad_ids colorfulscoop/tfdlg/tfdlg/generations.py community (archive-listed) unverified MIT (permissive) · 434564b8c9520cf5 · report
filter_to_topk colorfulscoop/tfdlg/tfdlg/generations.py community (archive-listed) unverified MIT (permissive) · ec70453aadfa3cc2 · report
get colorfulscoop/tfdlg/tfdlg/activations.py community (archive-listed) unverified MIT (permissive) · c1a80ebe76a998e9 · report
import_class colorfulscoop/tfdlg/tfdlg/utils.py community (archive-listed) unverified MIT (permissive) · 255a1a9413a38abc · report
load_model colorfulscoop/tfdlg/tfdlg/utils.py community (archive-listed) unverified MIT (permissive) · 932caee3efef6087 · report
scaled_dot_product_attention colorfulscoop/tfdlg/tfdlg/models.py community (archive-listed) unverified MIT (permissive) · 3864ff9606edf68a · report

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Absolute Position EncodingsAdamAttentionBPEDense ConnectionsDropoutLabel SmoothingLayer NormalizationLinear LayerMulti-Head AttentionPosition-Wise Feed-Forward LayerReLUResidual ConnectionSoftmaxTransformer

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections