Sliding-window and interleaved attention

Attention & transformers · component · 2020 · text

What it is

Most layers attend only locally while a few attend globally, cutting KV-cache cost at long context.

When to use it

Long-context LLMs: Mistral's window attention, Gemma's 5:1 local-to-global interleave.

Caveats

A token can only see beyond its window indirectly, through stacked layers or the occasional global layer, so long-range information can arrive weakened or not at all. Window size and how often global layers appear are tuning choices with no universal best setting.

Key ideas

  • Each token attends only to a fixed window of neighbours, so cost grows linearly with length
  • Stacking layers widens the effective receptive field, as in a CNN
  • Interleaving local layers with a few global-attention layers restores long-range access cheaply

Related architectures

Original paper

Longformer: The Long-Document Transformer (2020, arXiv)

Browse all 198 architectures

The architecture landscape, in one place.

Two things get called “ML architecture”: the classical statistical model families, and the neural network wirings. Both are here, tagged by what they are and what data they eat.

Start from your problem

Architectures

0 shortlisted