What's the 'attention sink' phenomenon, and how does StreamingLLM exploit it?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
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.
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.
What an interviewer would ask next. Try answering before peeking at the approach.
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.