Batch norm normalizes each feature across the batch, so its statistics depend on batch composition and on sequence padding, and it behaves differently at inference where it uses running averages. Layer norm normalizes across the features of a single token, independent of batch and sequence length, which makes it stable for variable length sequences, small batches, and autoregressive decoding.
Why interviewers ask this
This distinguishes people who know which layer to use from people who know why. The interviewer is probing whether you understand what axis each normalization operates over and the practical consequences: batch dependence at inference, trouble with padding and small batches, and the train and test discrepancy. Mentioning pre norm versus post norm placement and RMSNorm is a strong bonus.
How to structure your answer
- Say which axis each one normalizes over.
- Explain why batch statistics break for variable length sequences.
- Note the train and inference discrepancy in batch norm.
- Mention pre norm placement and RMSNorm as the modern default.
Example answer
They normalize over different axes. Batch norm takes a single feature and normalizes it across all the examples in the batch. Layer norm takes a single example, or a single token, and normalizes across its features. That difference decides everything else. With text you have variable length sequences and padding, so batch statistics get polluted by pad tokens and shift depending on what happened to be batched together. Batch norm also carries the train and inference mismatch, where you train on batch statistics and serve on running averages, and during autoregressive decoding you are often generating one token at a time with a batch of one, where batch statistics are meaningless. Layer norm has no batch dependence at all, so training and inference are identical and batch size does not matter. On placement, modern transformers put the norm before the sublayer rather than after, because pre norm keeps the residual path clean and lets you train deep stacks without a delicate warmup schedule. Most current models have also moved to RMSNorm, which drops the mean centering and just rescales, because it is cheaper and works about as well.
Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.
See how it worksFollow-up questions to expect
- What breaks if you use batch norm with a batch size of one?
- Why does pre norm train more stably than post norm?
- What does RMSNorm drop, and why does that turn out to be fine?
Related machine learning engineer questions
Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.
Predict my questions