A mask sets scores for future positions to negative infinity before softmax, so each token can attend only to itself and earlier tokens.
It is required in decoders and language-model training, where the model predicts the next token and must not see the answer.
It also allows training on all positions of a sequence in parallel in a single forward pass.
Loading…