Contrast Batch Normalization and Layer Normalization for Sequence Models
Last updated: November 29, 2026
Quick Overview
Explain how batch normalization and layer normalization compute their statistics, why Transformers for language use layer normalization or RMSNorm, and what breaks if you put batch normalization in an autoregressive decoder.
0
0
0 solved
Explain how batch normalization and layer normalization compute their statistics, why Transformers for language use layer normalization or RMSNorm, and what breaks if you put batch normalization in an autoregressive decoder.
Google interviewers use this to separate candidates who have only used vision models from those who understand why language models are built differently. They check the axes of normalization, train-versus-inference behavior, and the specific failure for variable-length, causal sequence data.
What the Interviewer Expects
- States the axes over which each method computes mean and variance
- Explains running statistics in batch norm and the train versus inference mismatch
- Explains why padding and variable-length sequences corrupt batch statistics
- Identifies the causal leakage problem in autoregressive decoding
- Describes RMSNorm and why it is cheaper
- Mentions small per-device batches in large-scale training
Key Topics to Cover
How to Approach This
- Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
- Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
- Feature engineering is often more impactful than model selection.
- Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
- Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
- What do the learned gain and bias parameters do after normalization?
- Why does RMSNorm drop mean centering, and does it hurt quality?
- Where does group normalization fit in, and when would you use it?
- How does normalization placement (pre versus post) affect stability?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Explore ML Interview PrepSample Answer
Clarify
Activations have shape (batch , sequence , features ). The question is which axes each method normalizes over and why that matters for language models served one token at a time....
Approach
Batch norm: for each feature, compute mean and variance across the batch (and spatial or time positions), keep running averages for inference. Layer norm: for each token independently, compute mean an...