Complete the RMSNorm formula
RMSNorm(x) = gamma * x / sqrt(mean(x^2) + eps). One learnable scale `gamma` per feature, and a small `eps` (typically 1e-5 or 1e-6) under the square root for numerical stability.
Imagine each token in the model has a list of 4096 numbers. Some lists are bigger overall, some smaller. RMSNorm just measures the typical size of those numbers (the root mean square) and divides everything by that, so every list ends up at roughly the same overall scale. Then it lets the model learn one knob per position to fine-tune the final scale. That is the whole operation. The two missing pieces of the puzzle are the knob name (gamma) and the tiny safety constant under the square root (epsilon) that stops the division from blowing up when the input is all zeros.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
RMSNorm is one of the simplest swaps in the 2017-to-2026 transformer transition: drop the mean subtraction and the bias from LayerNorm, keep the scale. Faster, smaller, no quality loss. This question is asking whether you have the formula on muscle memory; if you do, the rest of the LayerNorm versus RMSNorm discussion falls out naturally.
Building the formula from the name
The name is the formula. Root Mean Square. Square each element of x, take the mean over the feature axis, take the square root. That gives you the RMS magnitude of x. Divide x by that magnitude to rescale it to unit RMS. Then multiply by a learnable per-feature scale gamma.
The one extra piece is the numerical-stability constant eps, added inside the square root: sqrt(mean(x^2) + eps). Without it, if x is exactly the zero vector, you would divide by zero. With it, the denominator is floored at sqrt(eps), which keeps the operation stable.
No other terms. No mean subtraction. No bias. The formula is just gamma * x / sqrt(mean(x^2) + eps).
Situations where this technique stops working.
2–4 min · Everything important, quickly.
| Aspect | LayerNorm | RMSNorm |
|---|---|---|
| Normalizing quantity | `(x - mean(x)) / sqrt(var(x) + eps)` | `x / sqrt(mean(x^2) + eps)` |
| Mean subtraction | Yes | No |
| Learnable params per feature | 2 (gamma, beta) | 1 (gamma) |
| Reductions over feature axis | 2 (mean, then variance) | 1 (mean of x^2) |
| Typical eps | `1e-5` | `1e-5` or `1e-6` |
| Compute cost | Baseline | Roughly 30-50% faster |
Real products, models, and research that use this idea.
- Llama 3.1 8B and 70B both use RMSNorm with eps `1e-5` in every block (two per block, plus a final RMSNorm before the unembedding head).
- Mistral Large and Mixtral 8x22B use RMSNorm with eps `1e-5`.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy is gamma per-feature (shape `(d_model,)`) rather than a single scalar?
Different features in the residual stream serve different roles and have different natural scales. A per-feature gamma lets the model recover those distinct scales after normalization; a scalar gamma would force every feature to share one post-norm magnitude.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Adding a learnable bias term. RMSNorm deliberately omits the bias that LayerNorm has; only one learnable parameter per feature.
60 second bullets to scan on the way to the call.
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.