The Wider Lens logoThe Wider Lens
← All topics

Advanced

What is Attention?

The mechanism that lets models focus on what matters.

Attention is the core operation of the Transformer: for each token, the model computes how much 'attention' to pay to every other token, then blends their information accordingly. The famous formula — softmax(QK^T/√d)V — is just weighted averaging with learned weights.

Multi-head attention runs this process many times in parallel with different learned projections, letting the model track grammar, coreference, and long-range dependencies simultaneously.

Why it matters: attention is what gives Transformers their memory of context, but its cost grows quadratically with sequence length — the fundamental reason long context is expensive, and why efficient-attention research (FlashAttention, linear attention) is so active.

Key points

  • Weighted averaging over all tokens
  • Multi-head = many relations in parallel
  • Quadratic cost drives long-context expense
  • FlashAttention made it far more efficient