Layer normalization

Layer normalization rescales the values inside a neural network so that each example's set of values has a steady average and spread, which keeps training stable; transformers apply it around every main block.

As numbers pass through dozens of layers in a deep network, their scale can drift, growing too large or shrinking towards zero. That makes training slow or unstable. Normalisation pulls them back into a standard range: subtract the average, divide by the spread, then let the network apply a learned scale and offset of its own.

Layer normalization was introduced in July 2016 by Jimmy Lei Ba, Jamie Ryan Kiros and Geoffrey Hinton. The earlier batch normalization computed its averages across a batch of examples. Layer normalization computes them across all the values in one layer for a single example, so it does exactly the same thing during training and use, and it works for recurrent networks that process sequences step by step. The authors reported that it substantially cut training time.

It became a fixed part of the transformer. The 2017 design added each sub-layer's output to its input through a residual connection and then normalised the result. A 2020 study by Ruibin Xiong and colleagues showed that this placement, now called Post-LN, produces large gradients near the output at the start of training, which is why such models needed a careful learning-rate warm-up. Moving the normalisation inside the residual branch, before each sub-layer, gave well-behaved gradients and let the warm-up be dropped. Meta's LLaMA models, published in February 2023, used this pre-normalisation for training stability.

A lighter variant, RMSNorm, was proposed in 2019 by Biao Zhang and Rico Sennrich. It skips subtracting the average and only divides by the root mean square of the values. The authors found it performed about as well as layer normalization while cutting running time by 7% to 64%, depending on the model. LLaMA adopted it.

Normalisation rarely makes headlines on its own, but because it sits in every layer, choices about which kind to use and where to put it affect whether a very large training run converges smoothly. Architecture tables in technical reports usually list it alongside the attention type and positional encoding.

Common questions

What is the difference between layer normalization and batch normalization?

Batch normalization computes its statistics across a batch of different examples, so its behaviour depends on what else is in the batch. Layer normalization computes them across the values of one layer for a single example, so it behaves the same in training and use and suits sequence models such as transformers.

What is the difference between Pre-LN and Post-LN transformers?

Post-LN, the original 2017 design, normalises after adding each sub-layer's output back to its input. Pre-LN normalises the input before each sub-layer. A 2020 study found Pre-LN gives better-behaved gradients at the start of training and removes the need for a learning-rate warm-up.

What is RMSNorm?

RMSNorm is a simpler form of layer normalization that only rescales values by their root mean square and does not subtract the average. Its 2019 authors reported similar accuracy with 7% to 64% less running time, and Meta's LLaMA models use it.

Finding more

Search for "layer normalization transformer", "pre-LN vs post-LN" or "RMSNorm" to see how normalisation choices are made. The original papers on arXiv and the architecture sections of open model technical reports are the most reliable sources. Deep learning textbooks and university course notes cover the general idea of normalisation and why it helps training.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.