What's the structural limitation of pure sliding window attention, and how does BigBird address it?
Sliding window attention is local-only; long range info crawls layer by layer. BigBird adds global tokens so any pair is reachable in two hops.
Picture a long line of people passing notes, where each person can only talk to their immediate neighbors. A note from one end takes many small steps to reach the other end, and it can get garbled along the way. BigBird gives a few people in the line megaphones. Anyone in the line can shout to a megaphone holder, and that megaphone holder can shout back to anyone. Now a message from any position can reach any other in one quick step through a megaphone. You still keep the local chatter, which is cheap, and you also get the broadcast capability for the important stuff.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Sparse attention designs trade direct long range information flow for sub-quadratic compute. The natural first move, a sliding window, is cheap and easy to implement but loses something real on tasks that need to connect distant tokens.
BigBird is the canonical local plus global plus random template that addresses the lost reach without giving back the cost savings. The sections below walk sliding window's specific failure mode, the three pieces BigBird combines, why the combination recovers expressivity, how Longformer and Mistral choose differently, and where this whole family fits in the modern long context stack.
Sliding window attention and its limitation
Each token attends to ±W neighbors. The total cost is O(n · W), linear in n, and the kernel is hardware-friendly because the band aligns with contiguous memory access patterns.
The structural cost is an information bottleneck across distance. A relationship between positions i and j has to propagate through |i-j|/W layer hops, with each hop squeezing the signal through the intermediate token's residual stream. Long range relationships end up weakly represented even when the model has enough depth to reach them in principle.
A concrete example. With W = 512 and 24 layers, the theoretical reach is L · W = 12288 positions. That covers a 16k context just barely, but the signal at the far end has passed through 24 intermediate token residual streams, each of which mixes the propagating signal with whatever else that intermediate token is carrying. For tasks where the answer at position 12000 needs sharp, specific information from position 0, this is unreliable.
Sliding window reach is L · W in theory, but every hop is lossy in practice. Direct connections beat telephone chains for sharp long range dependencies.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
| Pattern | Complexity | Long range flow | Examples |
|---|---|---|---|
| Full attention | O(n²) | Direct any to any | Standard transformer |
| Sliding window only | O(n·W) | Multi-hop through layers (lossy) | Mistral 7B |
| Local + global (Longformer) | O(n·W + n·G) | 2-hop via global tokens | Longformer |
| Local + global + random (BigBird) | O(n·(W+G+R)) | 2-hop via global, more connectivity | BigBird |
| Dilated (LongNet) | O(n log n) | Multi-scale dilation | LongNet |
Real products, models, and research that use this idea.
- BigBird: used for long document NLP tasks like NaturalQuestions and ArXiv summarization at 4096-8192 tokens.
- Longformer: widely adopted for long document tasks; 'local plus global' template without random attention.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy has dense attention with FlashAttention largely replaced sparse attention for long context LLMs?
FlashAttention v2/v3 made dense attention memory efficient enough to scale to 100K+ tokens on modern hardware. Combined with positional encoding extensions (RoPE scaling, YaRN, ALiBi), you get long context without sacrificing direct any to any information flow. Sparse attention's complexity savings matter less when memory is no longer the bottleneck, and sparse designs always sacrifice some expressivity.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Treating sliding window as a drop in efficient replacement for full attention. It is, until you need long range dependencies, and then the multi-hop information path through intermediate tokens becomes the new bottleneck.
60 second bullets to scan on the way to the call.
Define sliding window attention in terms of W local neighbors per token
Structural limitation of pure local attention on long range information flow
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.