Attention Mechanism
An attention mechanism is a neural-network operation that lets each output position weigh every input position by learned relevance scores, replacing fixed-window context with content-addressed lookup.
AIDOLS Research Team · Editorial standards
Full definition
Attention computes a weighted sum of value vectors, where weights come from the dot product of a query vector and key vectors, scaled and softmaxed. Self-attention applies this within a single sequence so every token can attend to every other token in O(n²) time. Multi-head attention runs the operation in parallel across multiple learned subspaces. Vaswani et al. introduced scaled dot-product attention in the 2017 "Attention Is All You Need" paper, which underpins every modern large language model.
Why it matters
Attention is the single architectural primitive that made trillion-parameter language models tractable. Quadratic cost in sequence length is also the dominant driver of long-context inference price — buyers should ask vendors how attention is computed (vanilla, FlashAttention, paged) when comparing token economics.
Example
When GPT-4 reads "The trophy did not fit in the suitcase because it was too large," self-attention links "it" to "trophy" rather than "suitcase" via learned attention weights — the resolution is computed, not hard-coded.
Next steps
Related terms
- Transformer Architecture (Components)Transformer architecture is the internal design of a transformer model: a stack of identical blocks, each combining multi-head self-attention, a position-wise feed-forward network, residual connections and layer normalization, arranged as an encoder, a decoder or both. For what the transformer is and why it dominates AI, see Transformer.
- TransformerThe transformer is a neural-network architecture built around the self-attention mechanism that has become the dominant model design for language, vision, audio, and multimodal AI since 2017.
- Large Language Model (LLM)A Large Language Model (LLM) is a deep neural network — almost always a transformer — trained on hundreds of billions to trillions of words to predict the next token, and to generate, summarize, translate, or reason over text.
- Context WindowA context window is the maximum amount of text — measured in tokens — a language model can read and reason over in one inference call, equivalent to the model's working memory for that turn.
More models terms
- Encoder-DecoderAn encoder-decoder model is a neural architecture with two stacks: an encoder that compresses input into a representation and a decoder that generates output from it, with cross-attention linking the two.
- Autoregressive ModelAn autoregressive model generates output one token at a time, where each new token is conditioned on every previous token in the sequence, producing text by repeated next-token prediction.
Source & further reading
Primary source: Vaswani et al. — "Attention Is All You Need" (NeurIPS) (2017).
Citation policy: this entry is part of the AIDOLS AI Implementation Glossary and may be quoted for research, journalism, and education with attribution to aidolsgroup.com/en/glossary/attention-mechanism/.