Sliding-window and interleaved attention
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)