Concept notebookChecking saved investigationReading browser-local route memory before showing a continuation.

Layer Normalization & RMSNorm

Normalize one token/example vector across features: LayerNorm centers and scales, while RMSNorm keeps RMS-based scaling without mean-centering.

published · difficulty 3/5 · 14 min read

01

01

Intuition

Build the mental picture first so the rest of the page has something to attach to.

PredictName the object in plain language, then predict what should change.Leave with one reusable mental picture before notation appears.

Deep networks are sensitive to scale.

If activations grow over layers, gradients can explode. If activations shrink, gradients vanish. Normalization methods keep the signal in a "reasonable range" so training is stable.

Transformers almost always use LayerNorm (or RMSNorm) instead of BatchNorm because:

  • sequence models often have small or variable batch sizes,
  • we want behavior that does not depend on other examples in the batch,
  • decoding/inference should behave the same as training.

RMSNorm is a simplification introduced by Zhang and Sennrich: it drops the mean-centering step and normalizes by the root mean square.

Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

02

02

Math

Translate the story into symbols, assumptions, and a derivation you can inspect.

InspectTrack the same object through the notation and check each symbol.Leave with the invariant the equations preserve.

For a vector of activations xRdx\in\mathbb R^dxRd (for one token / one example), LayerNorm is:

μ(x)=1di=1dxi,σϵ(x)=1di=1d(xiμ(x))2+ϵ,LN(x)=γxμ(x)σϵ(x)+β.\begin{aligned} \mu(x) &= \frac{1}{d}\sum_{i=1}^d x_i,\\ \sigma_\epsilon(x) &= \sqrt{\frac{1}{d}\sum_{i=1}^d (x_i-\mu(x))^2 + \epsilon},\\ \mathrm{LN}(x) &= \gamma \odot \frac{x-\mu(x)}{\sigma_\epsilon(x)} + \beta. \end{aligned}μ(x)σϵ(x)LN(x)=d1i=1dxi,=d1i=1d(xiμ(x))2+ϵ,=γσϵ(x)xμ(x)+β.

RMSNorm removes mean-centering and uses:

RMSϵ(x)=1di=1dxi2+ϵ,RMSNorm(x)=γxRMSϵ(x).\begin{aligned} \mathrm{RMS}_\epsilon(x) &= \sqrt{\frac{1}{d}\sum_{i=1}^d x_i^2 + \epsilon},\\ \mathrm{RMSNorm}(x) &= \gamma \odot \frac{x}{\mathrm{RMS}_\epsilon(x)}. \end{aligned}RMSϵ(x)RMSNorm(x)=d1i=1dxi2+ϵ,=γRMSϵ(x)x.

Two practical insights:

  • Normalization makes the layer output less sensitive to the overall scale of xxx.
  • In pre-norm transformers, you normalize before attention/MLP, which tends to improve gradient flow in very deep stacks.
Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

03

03

Code

Keep the implementation aligned with the notation so the algorithm is legible.

TraceMatch variables to symbols before reading the implementation.Leave with a runnable witness for the math.
import numpy as np

rs = np.random.RandomState(0)
x = rs.randn(8) * 2.0 + 3.0  # nonzero mean on purpose
eps = 1e-5

def layernorm(x):
    mu = x.mean()
    var = ((x - mu) ** 2).mean()
    return (x - mu) / np.sqrt(var + eps)

def rmsnorm(x):
    rms = np.sqrt((x ** 2).mean())
    return x / (rms + eps)

ln = layernorm(x)
rn = rmsnorm(x)
cos = float((ln @ rn) / (np.linalg.norm(ln) * np.linalg.norm(rn)))

print("mean(x), std(x):", round(float(x.mean()), 3), round(float(x.std()), 3))
print("cos(LN, RMS):", round(cos, 3))
print("LN mean/std:", round(float(ln.mean()), 3), round(float(ln.std()), 3))
print("RMS mean/rms:", round(float(rn.mean()), 3), round(float(np.sqrt((rn ** 2).mean())), 3))
Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

04

04

Interactive Demo

Use direct manipulation to connect the explanation to a moving system.

ManipulateChange one control and predict the visible response before reveal.Leave with the observed invariant or a repaired model.

Live Concept Demo

Explore Layer Normalization & RMSNorm

The stage is code-native and interactive. Use it to test the explanation against the mechanism.

difficulty 3/5undergraduatecode-aligned
Demo inquiry checkpoint

Manipulate one control and predict the visible change.

01Choose lensTrace a quantity
02ObserveDemo state pending
03GroundName the equation, invariant, or control that explains it.
04CarryNext: Long Context Engineering: RoPE Scaling, KV Compression & Memory Optimization

Choose what to inspect in Layer Normalization & RMSNorm. This shared fallback is an observation guide, not evidence of learning.

Loading interactive demo...

Use the demo to see:

  • how centering (LayerNorm) vs non-centering (RMSNorm) changes the direction of a vector,
  • how learned γ,β\gamma,\betaγ,β let the network keep normalization while still representing useful scales,
  • why normalization is a core stability trick in transformer training.
Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

4/4 sections ready

Concept: Layer Normalization & RMSNorm

What is the smallest example that makes Layer Normalization & RMSNorm click without losing the math?

BeforeScaled Dot-Product Attention & Transformer LayersNow4/4 sections readyTryManipulate one control and predict the visible change.NextLong Context Engineering: RoPE Scaling, KV Compression & Memory Optimization
Object contextAttention & Transformers
ConceptLearner lens

Layer Normalization & RMSNorm

What is the smallest example that makes Layer Normalization & RMSNorm click without losing the math?

Mode questionCan I say the mechanism back in one sentence before I reveal anything?

Start with the prediction checkpoint, then compare the reveal to the mental model.

Take this move

Study modes

Keep the object fixed; change the lens.

Route back through the notebook

Carry the same object through intuition, math, code, and demo.

4/4 sections ready
Carry inScaled Dot-Product Attention & Transformer Layers

Bring the mental model from Scaled Dot-Product Attention & Transformer Layers; this page will reuse it instead of restarting from zero.

Work hereLayer Normalization & RMSNorm

Normalize one token/example vector across features: LayerNorm centers and scales, while RMSNorm keeps RMS-based scaling without mean-centering.

Carry outLong Context Engineering: RoPE Scaling, KV Compression & Memory Optimization

The next edge should feel earned: use the demo prediction here before following Long Context Engineering: RoPE Scaling, KV Compression & Memory Optimization.

After The First Pass

Turn the concept into an inspected object.

The lower panels are one second act: keep the object fixed, inspect it visually, check source boundaries, practice transfer, then attach the research question.
ConceptLayer Normalization & RMSNormAttention & Transformers

Mechanism Storyboard

See the idea move before the page explains it

Normalize one token/example vector across features: LayerNorm centers and scales, while RMSNorm keeps RMS-based scaling without mean-centering.

Demo notes open01 / Intuition
Editorial transformer illustration of activation vectors being centered, scaled, and stabilized by normalization.
Prediction lens

Start with the picture, metaphor, or geometric mechanism.

Commit first

Before reading further, choose the kind of change Layer Normalization & RMSNorm should make visible.

Visual Inquiry

Make the image answer a mathematical question

Normalize one token/example vector across features: LayerNorm centers and scales, while RMSNorm keeps RMS-based scaling without mean-centering.

4/4 stages readyDemo notes connected
Prediction

Which visible object should carry the first intuition?

Commit first

Pick the cue that should make Layer Normalization & RMSNorm easier to reason about before the page gives the answer.

Source Grounding

Canonical references for the mechanism on this page.

Object - ConceptLayer Normalization & RMSNormQuestion

What is the smallest example that makes Layer Normalization & RMSNorm click without losing the math?

concept:attention-transformers/layer-normalization
Boundary

sources: ba-2016-layer-normalization, zhang-2019-rmsnorm

Check

Open the closest source note before trusting the local explanation.

Evidence

2 selected-object sources shown first; 2 references total.

Next move

Audit the claim boundary, then ask from the same selected object.

selected object source · paper · 2016Layer NormalizationBa, Kiros, and Hinton
Located CF editorial boundary

Direct PDF. Grounds LayerNorm statistics over hidden units in a layer for one training case/current time step, with adaptive gain/bias applied after normalization.

Used here as

Ba et al. compute LayerNorm statistics over all hidden units in one layer for a single training case and apply learned gain/bias after normalization. Zhang and Sennrich review LN's mean/s...

Caveat

Checks only normalization mechanics and finite-vector witnesses. The token/example wording maps papers' per-case/per-layer statistics to the page's transformer frame; this does not verify...

Open source
selected object source · paper · 2019Root Mean Square Layer NormalizationZhang and Sennrich
Located CF editorial boundary

Direct PDF. Grounds RMSNorm as RMS-based rescaling that removes the mean statistic; reviews LayerNorm's mean/std form and gives RMSNorm's rescaling-invariance frame.

Used here as

Ba et al. compute LayerNorm statistics over all hidden units in one layer for a single training case and apply learned gain/bias after normalization. Zhang and Sennrich review LN's mean/s...

Caveat

Checks only normalization mechanics and finite-vector witnesses. The token/example wording maps papers' per-case/per-layer statistics to the page's transformer frame; this does not verify...

Open source

Claim Review

Normalize one token/example vector across features: LayerNorm centers and scales, while RMSNorm keeps RMS-based scaling without mean-centering.

Object - ConceptLayer Normalization & RMSNormQuestion

What is the smallest example that makes Layer Normalization & RMSNorm click without losing the math?

concept:attention-transformers/layer-normalization
Boundary

sources: ba-2016-layer-normalization, zhang-2019-rmsnorm

Check

Treat every claim as provisional until source support and a local witness agree.

Evidence

1 structured claim check on this concept.

Next move

Run the prediction or practice transfer before asking for a grounded review.

1 CF editorial source-scope review recorded

Publisher-side editorial review is not independent replication. Claims without it still need exact source-support review. 2 references and 3 local witnesses are available for inspection.

LayerNorm normalizes one token/example vector across its features by subtracting that vector's mean and dividing by its standard deviation, then applying learned gain/bias. RMSNorm uses the same per-vector rescaling frame but omits mean-centering and divides by the root mean square.
Used here as

Ba et al. compute LayerNorm statistics over all hidden units in one layer for a single training case and apply learned gain/bias after normalization. Zhang and Sennrich review LN's mean/std form, define RMSN...

Local witness
Equation 1
μ(x)=1di=1dxi,σϵ(x)=1di=1d(xiμ(x))2+ϵ,LN(x)=γxμ(x)σϵ(x)+β.\begin{aligned} \mu(x) &= \frac{1}{d}\sum_{i=1}^d x_i,\\ \sigma_\epsilon(x) &= \sqrt{\frac{1}{d}\sum_{i=1}^d (x_i-\mu(x))^2 + \epsilon},\\ \mathrm{LN}(x) &= \gamma \odot \frac{x-\mu(x)}{\sigma_\epsilon(x)} + \beta. \end{aligned}
Equation 2
RMSϵ(x)=1di=1dxi2+ϵ,RMSNorm(x)=γxRMSϵ(x).\begin{aligned} \mathrm{RMS}_\epsilon(x) &= \sqrt{\frac{1}{d}\sum_{i=1}^d x_i^2 + \epsilon},\\ \mathrm{RMSNorm}(x) &= \gamma \odot \frac{x}{\mathrm{RMS}_\epsilon(x)}. \end{aligned}
Code witness 1import numpy as np rs = np.random.RandomState(0) x = rs.randn(8) * 2.0 + 3.0 # nonzero mean o...
Caveat

Checks only normalization mechanics and finite-vector witnesses. The token/example wording maps papers' per-case/per-layer statistics to the page's transformer frame; this does not verify norm placement, LLa...

Review stateCF editorial source-scope reviewClaim metadata: source checkedPublisher-side editorial review only; not independent replication. Check caveats and exact source scope.

Checked Ba Sec.3/RNN equations and Zhang/Sennrich Secs.3-4. Ba supports per-case/layer statistics over one activation vector with shared mu,sigma and learned gain/bias. Zhang/Sennrich review LN as mean/std scaling, define RMSNorm as a_i/RMS(a)*g_i, and state it removes the mean statistic. Local math/code/demo match finite-vector centering vs RMS-only scaling; transformer usage is not reviewed.

Reviewer: codex+oracle; reviewed 2026-05-07

Practice notebook

Use the idea, then test it somewhere new

Normalize one token/example vector across features: LayerNorm centers and scales, while RMSNorm keeps RMS-based scaling without mean-centering.

AttemptNo learning claim inferred
Object - ConceptLayer Normalization & RMSNormQuestion

What is the smallest example that makes Layer Normalization & RMSNorm click without losing the math?

concept:attention-transformers/layer-normalization
Boundary

sources: ba-2016-layer-normalization, zhang-2019-rmsnorm

Check

Use one state from Layer Normalization & RMSNorm to explain what changes, why it changes, and which assumption the explanation needs.

Evidence

No learner move yet; no learning state is inferred.

Next move

Write first, use only the help you need, then try a new case without it.

Explain

Use one state from Layer Normalization & RMSNorm to explain what changes, why it changes, and which assumption the explanation needs.

Hint 1

Reveal when your model needs a nudge.

Hint 2

Reveal when your model needs a nudge.

Hint 3

Reveal when your model needs a nudge.

Grounded object roomClose
Selected object routeAsk from this object; carry one invariant back.sources: ba-2016-layer-normalization, zhang-2019-rmsnorm
  1. ObjectConceptLayer Normalization & RMSNorm
  2. PredictBefore revealLayer Normalization & RMSNorm prediction
  3. WitnessCompare codeLayer Normalization & RMSNorm code witness 1
  4. RoomAsk groundedChecking local snapshot
ConceptLayer Normalization & RMSNormAttention & Transformers
Code witness comparisonLayer Normalization & RMSNorm code witness 1rs = np.random.RandomState(0)Prediction before revealLayer Normalization & RMSNorm predictionManipulate one control and predict the visible change.
Grounded room questionWhat is the smallest example that makes Layer Normalization & RMSNorm click without losing the math?Checking local snapshot

Research Room

Attach the question to an exact object

Pick the concept, equation, source, code witness, claim, misconception, or demo state before asking for help. The handoff stays grounded to that object.
Next local actionNo local draft saved yet

Open the draft below to save one note and next action in this browser.

conceptAttention & Transformers

Layer Normalization & RMSNorm

Anchored question

What is the smallest example that makes Layer Normalization & RMSNorm click without losing the math?

Source boundaryInspect source ids: ba-2016-layer-normalization, zhang-2019-rmsnormStable content-object key attached
Role lenses for this object

These are fixed, deterministic perspectives derived from the selected object. They do not represent people, community contributions, or independent review.

Learner evidence requestAsk what would make "Layer Normalization & RMSNorm" feel predictable rather than familiar.
Assumption

Source ids ba-2016-layer-normalization, zhang-2019-rmsnorm must support the exact object, not just the surrounding topic.

Source-checking summary

Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion.

Proposed experiment

Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo.

Next action

The learner can state the mechanism in their own words

Evidence4 checks
PredictionChecking carried observation
ActionReady for one action
AILearner handoff ready
Open source object
01PredictionChecking browser-local route memory
02EvidenceChecking for a carried observation
03BoundaryInspect source ids: ba-2016-layer-normalization, zhang-2019-rmsnorm
04Next moveSave one next action
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
Local action draft

This draft stays locally in this browser for concept:attention-transformers/layer-normalization.

No local draft saved.
Evidence to inspect
  • Source ids to inspect: ba-2016-layer-normalization, zhang-2019-rmsnorm
  • Definition, prerequisite, and contrast concept links
  • The equation or code witness that makes the concept operational
  • One demo state that shows the invariant instead of a slogan
What would resolve this
  • The learner can state the mechanism in their own words
  • The learner can name the prerequisite that would repair confusion
  • The learner can predict how the mechanism changes under one perturbation
Object-attached AI handoff

I am working in Continuous Function's research reading room. Object: concept - Layer Normalization & RMSNorm Object key: concept:attention-transformers/layer-normalization Context: Attention & Transformers Anchor id: concept/concept-notebook/attention-transformers/layer-normalization Open question: What is the smallest example that makes Layer Normalization & RMSNorm click without losing the math? Evidence to inspect: - Source ids to inspect: ba-2016-layer-normalization, zhang-2019-rmsnorm - Definition, prerequisite, and contrast concept links - The equation or code witness that makes the concept operational - One demo state that shows the invariant instead of a slogan Deterministic role lenses for this object: - Boundary: fixed perspectives, not people, community contributions, or independent review - Source-checking summary: Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion. - Proposed experiment: Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo. - Teach/transfer move: Turn the mechanism into one sentence that predicts a neighboring concept. - Assumptions: - Source ids ba-2016-layer-normalization, zhang-2019-rmsnorm must support the exact object, not just the surrounding topic. - The stable content-object key lets local drafts, prompts, and route memory attach without changing the source page. - The concept explanation is local atlas prose until checked against its math, code, and source support. - Prerequisite gaps should become a repair route, not a reason to leave the object vague. - Role-lens requests: - Learner: ask for "Ask what would make "Layer Normalization & RMSNorm" feel predictable rather than familiar." | assumption: Source ids ba-2016-layer-normalization, zhang-2019-rmsnorm must support the exact object, not just the surrounding topic. | next action: The learner can state the mechanism in their own words - Researcher: ask for "Source ids to inspect: ba-2016-layer-normalization, zhang-2019-rmsnorm" | assumption: The stable content-object key lets local drafts, prompts, and route memory attach without changing the source page. | next action: The learner can name the prerequisite that would repair confusion - Experimenter: ask for "Choose one variable or condition to perturb before asking for an explanation." | assumption: The concept explanation is local atlas prose until checked against its math, code, and source support. | next action: The learner can predict how the mechanism changes under one perturbation - Professor: ask for "Find the smallest transferable rule a learner could reuse without the AI." | assumption: Prerequisite gaps should become a repair route, not a reason to leave the object vague. | next action: Teach or transfer: Turn the mechanism into one sentence that predicts a neighboring concept. What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action. Current deterministic role lens for this object: - Role lens: Learner - Evidence request: Ask what would make "Layer Normalization & RMSNorm" feel predictable rather than familiar. - Assumption to keep visible: Source ids ba-2016-layer-normalization, zhang-2019-rmsnorm must support the exact object, not just the surrounding topic. - Proposed experiment: Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo. - Next action: The learner can state the mechanism in their own words

concept/concept-notebook/attention-transformers/layer-normalization concept:attention-transformers/layer-normalization