Skip to main content

Masked attention

Lesson notes

Why a generator can't peek: causal masking zeroes attention to future positions so training (all positions at once, teacher-forced) matches generation (one token at a time). The mask is the difference between BERT-style encoders that see everything and GPT-style decoders that must predict it.

Key ideas

  • Causal mask mechanics (upper-triangular −∞)
  • Teacher forcing and parallel training
  • Encoder vs decoder attention visibility

Further reading