The problem it solves
Read this sentence: The trophy would not fit in the suitcase because it was too big.
What does “it” refer to? The trophy. Now change one word: ...because it was too small. Now “it” is the suitcase. Nothing about the position of the word changed; the meaning of a nearby word flipped the reference.
A language system needs ways to connect related parts of a sentence. Attention is one important mechanism for doing that. The 2017 Transformer combined self-attention with other components in an architecture that made highly parallel training practical; it was not the first use of attention or the sole cause of later progress.
What attention does, in plain terms
In causal self-attention, a position can combine information from allowed positions in its prefix, including itself. Learned query and key representations produce weights, which mix value representations. Those weights depend on the input and layer. Other attention patterns, such as a bidirectional encoder’s, allow different connections.
In the trophy example, a causal decoder processing the earlier word “it” cannot attend to the later word “big”. Once the whole sentence is in its input, a later position used to answer the question can draw on both nouns and the adjective. This illustrates what information is available; it is not a measurement of any particular attention head’s weights.
Parallel attention operations using separately learned projections are called heads. Particular heads in studied models can show recognisable patterns, including syntactic relationships. That does not give every head a fixed job or make one weight map a complete explanation of the model’s answer.
Transformer layers repeatedly transform these representations. Their number and organisation vary by model, and they include components besides attention. It is useful to picture successive refinement, but not to assign grammar to all early layers and meaning to all later ones.
Why it replaced what came before
Many earlier sequence models used recurrent networks, which carry a state from one position to the next. They were not the only alternative: convolutional and bidirectional designs also existed. Recurrence creates a sequential dependency that is especially relevant when comparing training speed.
In a recurrent chain, a distant relationship can require information to pass through many steps. Within a sequence, the next recurrent state depends on the preceding one, limiting how much that part of the work can be parallelised. Other operations and separate sequences can still run in parallel.
Self-attention provides shorter connections between positions, and during training the known sequence positions can be processed in parallel, with a mask preventing access to future targets where needed. Generating a new autoregressive response is still sequential across output steps. This training advantage helped scaling; it does not guarantee perfect use of distant information or remove the need for data, hardware and other engineering.
The original paper is Attention Is All You Need, published in 2017 by Vaswani and colleagues. It describes the architecture, causal masking and translation experiments, and is freely available.
The cost, which you feel every day
For a dense attention calculation across a whole sequence, the number of token pairs grows roughly with the square of its length. Doubling the length gives about four times as many pairs. This is a scaling illustration for that operation, not a benchmark of total runtime, memory or the cost of every decoding step.
This helps explain some long-context engineering trade-offs:
- In dense attention, processing longer inputs increases work; the actual latency and memory use depend on the implementation and hardware.
- Engineers develop efficient exact implementations as well as sparse or approximate attention, caching and other architectures. These solve different parts of the cost problem.
- Larger advertised windows also depend on training, positional methods, memory and product design. They did not grow because of one approximation alone.
The limitation: a window is not comprehension
An advertised context limit describes a capacity, subject to the model and API’s input and output rules. It does not establish that every position is used equally well, or that every supplied document was included by the application.
Lost in the Middle, first circulated in 2023 and published in 2024, tested selected models on multi-document question answering and key-value retrieval. Performance often fell when relevant information was in the middle rather than at an end. It is a result for those models and tasks, not a universal accuracy curve for every current model.
For a fifty-page contract, first check that the relevant text was actually supplied. Even when page twenty-seven is within the window, a correct answer about clause thirty-four is not guaranteed. The model’s answer and a diagram of its architecture do not establish which passage it used.
What to try: supply the relevant passage directly, test different placements where useful, and ask about one section at a time. These are evaluation strategies, not guaranteed fixes. Check each material answer against the contract itself, using qualified help when the decision requires it.
Check your understanding
What was an important training advantage of the Transformer over a recurrent chain?
Pick the one you would defend. Your answer stays private.
Your place and first choices stay on this browser. Classroom credit is recorded separately.
Stuck on something?Ask Meenal, your AI tutor