Bring the mental model from Scaled Dot-Product Attention & Transformer Layers; this page will reuse it instead of restarting from zero.
Layer Normalization & RMSNorm
Normalize one token/example vector across features: LayerNorm centers and scales, while RMSNorm keeps RMS-based scaling without mean-centering.
01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
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.
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
For a vector of activations x∈Rd (for one token / one example), LayerNorm is:
RMSNorm removes mean-centering and uses:
Two practical insights:
- Normalization makes the layer output less sensitive to the overall scale of x.
- In pre-norm transformers, you normalize before attention/MLP, which tends to improve gradient flow in very deep stacks.
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
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))
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
Live Concept Demo
Explore Layer Normalization & RMSNorm
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Choose what to inspect in Layer Normalization & RMSNorm. This shared fallback is an observation guide, not evidence of learning.
Use the demo to see:
- how centering (LayerNorm) vs non-centering (RMSNorm) changes the direction of a vector,
- how learned γ,β let the network keep normalization while still representing useful scales,
- why normalization is a core stability trick in transformer training.
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
Concept: Layer Normalization & RMSNorm
What is the smallest example that makes Layer Normalization & RMSNorm click without losing the math?
Object contextAttention & Transformers
concept:attention-transformers/layer-normalizationLayer Normalization & RMSNorm
What is the smallest example that makes Layer Normalization & RMSNorm click without losing the math?
Start with the prediction checkpoint, then compare the reveal to the mental model.
Take this moveStudy modes
Keep the object fixed; change the lens.Route back through the notebook
Carry the same object through intuition, math, code, and demo.
Normalize one token/example vector across features: LayerNorm centers and scales, while RMSNorm keeps RMS-based scaling without mean-centering.
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.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.

Start with the picture, metaphor, or geometric mechanism.
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.
Which visible object should carry the first intuition?
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.
What is the smallest example that makes Layer Normalization & RMSNorm click without losing the math?
concept:attention-transformers/layer-normalizationsources: ba-2016-layer-normalization, zhang-2019-rmsnorm
Open the closest source note before trusting the local explanation.
2 selected-object sources shown first; 2 references total.
Audit the claim boundary, then ask from the same selected object.
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.
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...
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...
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.
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...
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...
Claim Review
Normalize one token/example vector across features: LayerNorm centers and scales, while RMSNorm keeps RMS-based scaling without mean-centering.
What is the smallest example that makes Layer Normalization & RMSNorm click without losing the math?
concept:attention-transformers/layer-normalizationsources: ba-2016-layer-normalization, zhang-2019-rmsnorm
Treat every claim as provisional until source support and a local witness agree.
1 structured claim check on this concept.
Run the prediction or practice transfer before asking for a grounded review.
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.
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...
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...
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-07Practice 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.
What is the smallest example that makes Layer Normalization & RMSNorm click without losing the math?
concept:attention-transformers/layer-normalizationsources: ba-2016-layer-normalization, zhang-2019-rmsnorm
Use one state from Layer Normalization & RMSNorm to explain what changes, why it changes, and which assumption the explanation needs.
No learner move yet; no learning state is inferred.
Write first, use only the help you need, then try a new case without it.
Use one state from Layer Normalization & RMSNorm to explain what changes, why it changes, and which assumption the explanation needs.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Write an attempt before asking the companion.
0 of 3 progressive hints opened.
This draft and any AI response do not establish mastery; a later unassisted case can.
- ObjectConceptLayer Normalization & RMSNorm
- PredictBefore revealLayer Normalization & RMSNorm prediction
- WitnessCompare codeLayer Normalization & RMSNorm code witness 1
- RoomAsk groundedChecking 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.Open the draft below to save one note and next action in this browser.
Layer Normalization & RMSNorm
What is the smallest example that makes Layer Normalization & RMSNorm click without losing the math?
These are fixed, deterministic perspectives derived from the selected object. They do not represent people, community contributions, or independent review.
Source ids ba-2016-layer-normalization, zhang-2019-rmsnorm must support the exact object, not just the surrounding topic.
Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion.
Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo.
The learner can state the mechanism in their own words
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays locally in this browser for concept:attention-transformers/layer-normalization.
- 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
- 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
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