Layer norm

Per-token mean-and-variance normalization that rescales each hidden vector before the next sublayer in a transformer block.

Layer norm keeps each token's hidden vector in a predictable range by using that token's own feature mean and variance, which makes it a clean fit for transformer blocks that cannot rely on stable minibatch statistics.

At a glance

Released

July 2016

Authors

Jimmy Lei Ba, Jamie Ryan Kiros, Geoffrey E. Hinton

Optimizes

  • Training Stability

What It Is

Layer normalization rescales one token's hidden vector by subtracting its feature mean, dividing by a stabilized feature standard deviation, then applying learned scale and shift. The statistics come from that one vector, not from the rest of the batch.

Why It Exists

Layer norm targets training stability in deep sequence models where batch statistics are either noisy or structurally inconvenient. It keeps residual-stream magnitudes from drifting too far before attention or feed-forward sublayers run.

How It Works

For one token position, layer norm measures the mean and variance across the hidden features in that vector, recenters and rescales the vector, then applies learned gain and bias. The switcher below keeps that path next to RMSNorm so you can see that the extra mean-centering step is the main structural difference.

Math Or Compute Schema

These two formulas apply to one token vector at a time. Layer norm subtracts the feature mean before scaling, while RMSNorm keeps only the scale correction.
Layer normalization
LN(x)=γ⊙x−μσ2+ϵ+β\mathrm{LN}(x) = \gamma \odot \frac{x - \mu}{\sqrt{\sigma^2 + \epsilon}} + \beta
xx
Hidden feature vector at one token position.
μ\mu
Mean of the features in x.
σ2\sigma^2
Variance of the features in x.
ϵ\epsilon
Small constant for numerical stability.
γ\gamma
Learned per-feature scale.
β\beta
Learned per-feature shift.
RMS normalization
RMSNorm(x)=γ⊙x1d∑i=1dxi2+ϵ\mathrm{RMSNorm}(x) = \gamma \odot \frac{x}{\sqrt{\frac{1}{d}\sum_{i=1}^{d} x_i^2 + \epsilon}}
xx
Hidden feature vector at one token position.
dd
Number of features in x.
ϵ\epsilon
Small constant for numerical stability.
γ\gamma
Learned per-feature scale.

Compared To Nearby Modules

Layer norm stays within one token, unlike batch norm, and it includes mean centering, unlike RMSNorm. Group norm also avoids batch coupling, but it normalizes channel groups rather than an entire token vector.
Comparison dimensionLayer NormRMSNormBatch Norm
Mean centeringYes; subtracts the token's feature meanNo; scales by root mean square onlyYes; uses the minibatch feature mean
Statistics scopeOne token or hidden vector at a timeOne token or hidden vector at a timeOne feature or channel across the minibatch
Fit for transformer blocksVery common and structurally simpleVery common in newer decoder-only LLMsUsually awkward for autoregressive token streams

Example Architectures

Layer norm appears throughout the original transformer family and many later encoder-decoder or decoder stacks. Even when a newer model switches to RMSNorm, layer norm remains the reference point for comparison.

Limitations And Tradeoffs

Layer norm adds mean-centering work that RMSNorm skips, and that extra step is not always needed. Some modern decoder stacks prefer the lighter RMSNorm rule when they want similar stability with slightly less computation.

Why It Still Matters

Layer norm is still one of the clearest ways to understand how transformer normalization works. Many papers explain newer normalization tricks by contrasting them with the layer norm baseline.

Tags

References

  1. Ba, Jimmy Lei, Jamie Ryan Kiros, and Geoffrey E. Hinton. "Layer Normalization." arXiv, 2016, https://arxiv.org/abs/1607.06450.