LinkedIn analytics tracking pixel for AIDOLS AI consulting website performance measurement
Models

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.

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.

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/da/glossary/attention-mechanism/.