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.

Google
Machine Learning
Software Engineer
Google
November 29, 2026
Software Engineer
Technical Screen
Machine Learning
Easy

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
Teacher forcing
Causal masking
Exposure bias
Autoregressive models
Sequence training
How to Approach This
  1. Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
  2. Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
  3. Feature engineering is often more impactful than model selection.
  4. Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
  5. 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 Prep
Sample Answer
Clarify

Model: decoder-only Transformer trained with next-token prediction on sequences x1,…,xTx_1, \ldots, x_T. Question: how training works in parallel and why generation can still go wrong....

Approach

Teacher forcing: the loss is ∑t−log⁡p(xt∣x<t)\sum_t -\log p(x_t \mid x_{<t}) where the prefix x<tx_{<t} is the true data, never the model's own predictions. To compute all TT terms in one pass, shift targets by one...


Submit Your Answer
Markdown supported