What is sparse attention?

Definition

Sparse attention is an attention pattern that limits which token pairs interact. Instead of computing every possible relationship in a sequence, the model uses local windows, selected global tokens, learned routing or another structured subset.

Reducing the number of comparisons can lower memory use and serving cost, especially for long contexts or media generation. The tradeoff is that a poorly chosen sparse pattern may miss important distant information, so designs must preserve the connections needed by the task.

ELI5

Sparse attention lets a model focus on selected parts of a long input instead of comparing every part with every other part. This reduces the amount of work and memory the model needs.

For example, when reading a long book, a model might focus mainly on nearby sentences plus a few important chapter markers. That can be faster, but a poor selection could cause it to miss a clue from a distant chapter.

How does sparse attention improve efficiency?

It computes fewer token-to-token relationships than full attention. This can reduce memory and processing requirements as the input sequence grows.

Does sparse attention reduce model quality?

It can if the pattern excludes useful information. Well-designed methods preserve important local and global connections while avoiding many low-value comparisons.

  1. K谩roly Zsolnai-Feh茅r beside the words Qwen Flash Gets Smarter
  2. The words Open Models Surge beside a rising three-bar graphic
    The Week Open Models Closed the Gap
    AI Search43m 53s1 VIEW
  3. Olive Song in glasses and a plain blue top against black beside the white and blue headline NATIVE MULTIMODAL AI.
  4. A few connected blue dots among scattered dots beneath the words Sparse Attention.
  5. Memory Hungry - Compute Light beside a flat memory stack feeding sparse compute nodes
  6. Thomas Wolf and Olive Song beside the words Million-Token Context
    Why AI Agents Need Million-Token Context
    AI Engineer20m 48s1 VIEW
  7. An illustrated open book with circuit shapes under the headline Open AI Breakthroughs.
  8. K谩roly Zsolnai-Feh茅r beside the words Powerful AI Gets Cheaper
  9. Blue code brackets and model nodes beside the words LONGCAT CODE TEST on black.
Definition card for sparse attention: What is sparse attention?

Sparse attention reduces transformer computation by allowing each token to attend to a selected subset of other tokens instead of comparing with every token.