Attention is the mechanism that lets a model, when processing one token, selectively pull in information from other tokens. Each token emits a query, a key, and a value; queries are matched against keys, a softmax turns the match scores into weights, and the weighted sum of values updates the token.

The breakthrough is that any token can attend to any other in a single, parallel step, unlike older recurrent models that passed information along a chain. This is the heart of the transformer.

Watch a sentence attend to itself in How a transformer thinks.