What's the 'attention sink' phenomenon, and how does StreamingLLM exploit it?
Explain the 'attention sink' phenomenon discovered by Xiao et al. 2023 (StreamingLLM). What is the phenomenon, why does it exist, and how does StreamingLLM exploit it to enable effectively unlimited length streaming generation?
Trained LLMs dump excess softmax mass onto the first few tokens. StreamingLLM keeps those sinks plus a recent window, unlocking 100K+ token streaming.
Imagine a party host who has to hand out exactly 100 percent of their attention to the room at every moment, no exceptions. When nothing important is going on, the host has to look somewhere, so they default to glancing at the first guests who walked in. Those first arrivals quietly soak up the leftover gaze. Now make the host only look at the most recent guests and ignore those early arrivals. The leftover attention has nowhere to go, the host gets flustered, and the conversation falls apart within minutes. StreamingLLM says: no matter how long the party runs, always let the host keep a corner of an eye on those first few guests.
Detailed answer & concept explanation~6 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
Walk the phenomenon and its softmax overflow valve explanation, the failure mode of naive sliding window, StreamingLLM's two part cache, the RoPE positional encoding constraint, the empirical context length gains, and the follow on research into explicit learned sinks.
| Approach | Cache content | Long context behavior | Notes |
|---|---|---|---|
| Naive sliding window (K tokens) | Last K tokens only | Collapses after first window | Sinks evicted → softmax has no overflow valve |
| StreamingLLM (4 sinks + K window) | First 4 + last K tokens | Coherent over arbitrarily long sequences | Sinks retained at original positions |
| Full long context training (e.g. Llama-3-128K) | Entire context | Native long context | Expensive to train; memory scales linearly |
| Position interpolation / YaRN | Entire context, rescaled positions | Extends trained range | Requires some fine-tuning; orthogonal to sinks |
Real products, models, and research that use this idea.
- StreamingLLM's GitHub release enabled Llama-2-7B to generate coherent text for millions of tokens, a viral demo at the time.
- Modern 2026 streaming serving stacks (vLLM, SGLang, TRT-LLM) implement sink aware KV management for very long stream chat sessions.
- Mistral Large 3's sliding window training accounts for this implicitly; the model is trained on sliding windows so the sinks as overflow valve mechanism adapts.
- Gemma 4, Llama 4 Maverick, and DeepSeek V4 are trained at long native context but still exhibit attention sinks empirically; the phenomenon is robust across architectures and scales.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow do attention sinks interact with RoPE positional encoding?
QWhy don't attention sinks shift to later positions during training?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating attention sinks as a bug or curiosity rather than a critical structural feature; or trying to fix streaming by extending the window without preserving the sinks.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.