What is teacher forcing when training a sequence-to-sequence decoder, and what is exposure bias?
Sequence models and transformers, Sequence-to-sequence models
Level L2 Elementary. Length Short. Nature Th Theoretical.
What's being asked
Whether you know the mismatch between how a decoder is trained and how it is used.
Key idea
Teacher forcing trains on the true prefix (the correct earlier tokens ), minimising , where is the source and the model. At inference the model conditions on its own predictions instead. Exposure bias is this train–test mismatch: the model never practised recovering from its own mistakes, so errors can compound.
Steps
- Define teacher forcing: at step the decoder input is the ground-truth token , not the model's prediction.
- Say why it is used: training is stable and fast. In a transformer, every position is trained in one parallel pass using a causal mask (hiding future tokens).
- Define exposure bias: at test time the prefix comes from the model, . The model was not trained on this distribution, so one early error can push later steps off track.
- Mitigations: scheduled sampling (feed in the model's own predictions with increasing probability), sequence-level training (such as minimum-risk or reinforcement-learning objectives) and beam search at decoding. Large pretrained models suffer less in practice.
Common mistakes
- Confusing teacher forcing with label smoothing, or with a teacher model in distillation.
- Thinking transformers do not use teacher forcing. Their parallel training is teacher forcing.
- Calling exposure bias a form of overfitting. It is a distribution shift between training and inference inputs.
How long your answer should be
4–5 sentences.
Read this
Previous in Sequence models and transformers: What is retrieval-augmented generation (RAG), and when should you choose it instead of fine-tuning an LLM (large language model)?
Next in Sequence models and transformers: How is causal (look-ahead) masking implemented in decoder self-attention? What is the mask for a sequence of length 4, and why are masked logits set to rather than the attention weights being set to 0?