PromptForge
AI Glossary

Models & architecture

Attention

Also known as: self-attention, attention mechanism

Definition

Attention is the mechanism that lets a model weigh how much each token should influence the interpretation of every other token. It is how a model resolves what a pronoun refers to, or which clause modifies which noun.

For each token, attention computes query, key and value vectors. The query is compared against every key to produce weights, and those weights determine how much each token's value contributes to the output. Repeated across many "heads" and layers, this builds increasingly abstract representations.

Different attention heads specialise. Some track syntax, some resolve coreference, some attend to positional patterns. This specialisation is emergent rather than designed.

Attention is also why prompt position matters. Models attend unevenly across long contexts, which produces the well-documented tendency to under-weight material in the middle of a long document.

Related terms

Put this into practice

Understanding the term is step one. Our free courses and tools let you actually use it.