How does sliding-window attention trade global context for reduced computational cost?
Last updated
Each token attends only to the previous w tokens, cutting compute to O(N·w) and capping the KV cache as a rolling buffer of size w.
Stacking layers widens the receptive field to roughly L·w (Mistral 7B: about 131k tokens), but this multi-hop path is lossy and hurts exact long-range retrieval.
Mitigations include interleaving global-attention layers (Gemma 2/3), global tokens (Longformer, BigBird), and attention-sink tokens for streaming (StreamingLLM).