Batch Normalization Versus Layer Normalization in Transformers
Last updated: November 29, 2026
Quick Overview
Explain how batch normalization and layer normalization compute their statistics, and why transformers for text use layer normalization (or RMSNorm) instead of batch normalization.
Amazon
November 29, 20260
0
0 solved
Explain how batch normalization and layer normalization compute their statistics, and why transformers for text use layer normalization (or RMSNorm) instead of batch normalization.
A short fundamentals check common in Amazon MLE phone screens for NLP and LLM teams. The interviewer wants the axes over which statistics are computed and the practical consequences for variable-length sequences and inference.
What the Interviewer Expects
- State which axes each normalization averages over
- Explain running statistics in batch norm at inference
- Explain why variable-length padded batches break batch norm
- Describe RMSNorm briefly
- Mention pre-norm versus post-norm
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
- Why is batch norm still common in CNNs for images?
- What happens to batch norm with a batch size of 1?
- Why does pre-norm train more stably in deep transformers?
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
Assume an activation tensor of shape (batch , sequence length , hidden )....
Approach
Batch norm normalizes each feature using mean and variance across the batch (and spatial or time positions), then applies a learned scale and shift; at inference it uses running averages from training...