Explain Teacher Forcing, Causal Masking, and Exposure Bias in Decoders
Last updated: November 29, 2026
Quick Overview
Explain how an autoregressive decoder is trained on all positions in parallel with teacher forcing and a causal mask, why this creates exposure bias at generation time, and how practitioners mitigate it.
0
0
0 solved
Explain how an autoregressive decoder is trained on all positions in parallel with teacher forcing and a causal mask, why this creates exposure bias at generation time, and how practitioners mitigate it.
A common fundamentals check in Google interviews for engineers joining Gemini, Translate, or speech teams. The interviewer verifies that you understand what the training loss actually conditions on and why train-time and generation-time behavior differ.
What the Interviewer Expects
- Explains teacher forcing as conditioning on ground-truth prefixes
- Shows the causal mask as an upper-triangular negative infinity mask
- Explains that one forward pass yields a loss at every position
- Defines exposure bias and its symptoms
- Lists mitigations such as scheduled sampling, sequence-level training, and RL fine-tuning
- Notes that large models suffer less than small ones
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 would happen if you forgot the causal mask during training?
- Why is scheduled sampling awkward for Transformers?
- How does preference or RL fine-tuning reduce train-test mismatch?
- How do you verify a mask is correct in a new attention kernel?
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
Model: decoder-only Transformer trained with next-token prediction on sequences . Question: how training works in parallel and why generation can still go wrong....
Approach
Teacher forcing: the loss is where the prefix is the true data, never the model's own predictions. To compute all terms in one pass, shift targets by one...