Attention
The mechanism that lets an AI decide which other words matter when interpreting each word — the core idea behind transformers.
When not to use it
- Very long sequences on a tight budget. Standard attention costs grow with the square of length, so a 100k-token input isn't ten times a 10k one — it's about a hundred times. At some point the answer is retrieval, not a bigger window.
- As an explanation of model reasoning. Attention weights show where the model looked, which is tempting to read as why it answered. Research is genuinely divided on whether that inference holds.
- Small, local, structured problems. If a fixed neighbourhood is all that matters, a convolution or a plain feed-forward net is cheaper and often better.
Reach for something else instead
- Convolutions win when the signal is local and translation-invariant — most image tasks, plenty of audio.
- State-space models (Mamba and kin) scale linearly with sequence length and are competitive on long sequences, though not yet at frontier-model quality across the board.
- Sparse and linear attention variants trade a little quality for a lot of length. Useful when you genuinely need the context and can't afford the quadratic bill.
Sources & further reading
- Bahdanau, Cho & Bengio (2014), Neural Machine Translation by Jointly Learning to Align and Translate — attention before transformers, and still the clearest motivation for it.
- Vaswani et al. (2017), Attention Is All You Need — the paper that dropped recurrence entirely.
- Jain & Wallace (2019), Attention is not Explanation — the counter-argument to reading attention weights as reasoning, and the reply, Attention is not not Explanation (Wiegreffe & Pinter, 2019), which is worth reading alongside it.
Primary sources, listed so you can check the claims on this page rather than take them on trust.
Where people go wrong
- Reading attention maps as interpretability. They're suggestive, not evidence.
- Assuming more context is free. Doubling the prompt roughly quadruples attention cost and can lower answer quality by burying the relevant part.
- Confusing attention with the transformer. Attention is one mechanism inside the architecture; the block also has feed-forward layers, residuals, and normalisation doing real work.