A mask that stops attention from looking at padding tokens added to make sequences the same length.
An encoder-decoder model has a second kind of attention. In cross-attention, the queries come from the decoder's tokens and the keys and values come from the encoder's outputs. The score table is rectangular: one row per token being written, one column per source token. Source positions that are padding get -inf before the softmax, the padding mask, so no decoder token reads them.
Try it now
Press Next. Rows are the token reading, columns the token being read. Struck cells are blocked.
attention mask: A grid of allowed and blocked positions that sets which tokens each token may attend to.
BERT: Google's 2018 encoder model, trained by hiding words and guessing them from both sides. Its descendants still power much search and classification.
bidirectional: Reading in both directions: each token can look at the words before and after it, as encoders like BERT do.
contrastive learning: Training that pulls the embeddings of matching pairs (like a question and its answer) together and pushes mismatched pairs apart.
cross-attention: Attention where one sequence looks at another, such as a translation model's decoder reading the encoder's output.
cross-encoder: A model that reads a query and a document together and gives one relevance score. More accurate than comparing embeddings but slower, so it reranks a short list.
encoder: A transformer that reads the whole text at once to understand it, used for embeddings and classification.
masked language modeling: Training by hiding some tokens and asking the model to guess them from the words on both sides. It's how BERT learned.
mean pooling: Turning a text's token vectors into one vector for the whole text by averaging them.
Keep learning
More in plain English.
1286 terms in the glossary, each with the lesson that teaches it.