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 y<t∗), minimising −∑tlog⁡pθ(yt∗∣y<t∗,x), where x is the source and pθ the model. At inference the model conditions on its own predictions y^<t instead. Exposure bias is this train–test mismatch: the model never practised recovering from its own mistakes, so errors can compound.

Steps

  1. Define teacher forcing: at step t the decoder input is the ground-truth token yt−1∗, not the model's prediction.
  2. 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).
  3. Define exposure bias: at test time the prefix comes from the model, y^<t. The model was not trained on this distribution, so one early error can push later steps off track.
  4. 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

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?