Practice free →
HomeClaudeaifoundationstransformer_attention › Why does the decoder need to mask future positio…

Why does the decoder need to mask future positions in self-attention?

ATo match the encoder's bidirectional attention pattern
BTo prevent gradient explosion on long token sequences
CTo preserve the auto-regressive property at inference
DTo reduce computational cost during training time
Answer & Solution
Correct answer: C. To preserve the auto-regressive property at inference
At inference, the decoder generates one token at a time. If position i could attend to positions j > i during training, the train/test distributions diverge. Masking out illegal connections (set to −∞ before softmax) preserves the auto-regressive property.
Solve this in the app — Claude practice & 24k+ MCQs →
Related questions