Softmax forces unit attention mass, so models learn to park leftover weight on early tokens; evict them in a sliding cache and every distribution shifts, collapsing generation quality.
Imagine a kid given a stack of stickers and told they must use every single one, even on a worksheet where most boxes do not need a sticker. Eventually the kid quietly piles the leftover stickers in the top-left corner of the page where no one ever looks. The corner becomes a parking lot for unused stickers. Now imagine a teacher tears off the top-left corner of every worksheet to save paper. The kid has nowhere to dump leftovers, panics, and starts putting stickers in random places that ruin the assignment. The same thing happens inside a transformer when you erase the first few tokens from its memory.
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.
If you load a trained transformer and plot the attention weights for any layer, you will see a striking pattern: large stripes of attention mass on the leftmost few columns, often dominated by token 0. The pattern shows up in essentially every causal language model, from GPT-2 through Llama 3 and DeepSeek-V3. It does not depend on what the token at position 0 actually is. Replace it with a different token and the next training run rebuilds the same pattern.
This is the attention sink. It is one of the most important emergent properties of trained transformers for practical inference, because ignoring it breaks long-context generation. The deep dive walks through why it exists, what it does at inference, how production systems preserve it, and what alternative architectures avoid it.
Where the sink comes from: softmax under causal masking
Each attention head computes a probability distribution over the keys visible to the current query. The distribution comes from softmax applied to scaled dot products.
The distribution sums to exactly 1 over visible positions. This is a hard mathematical constraint, not a soft preference. When the query has no genuine match among the keys, the mass cannot just disappear; the head still outputs a unit total.
Now consider causal masking. Token 0 is visible to every position. Token 1 is visible to every position from 1 onward. Earlier positions have maximal visibility. During training, when a head needs to absorb no-op mass somewhere stable, the natural choice is the position that every query can see. Token 0 wins by default.
The pattern emerges within the first few thousand training steps in most experiments and stays through the entire pretraining run. It is not an artifact of any particular dataset or initialization; it is the equilibrium of optimizing a softmax-based loss under a causal mask.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- StreamingLLM (Xiao et al. 2023) keeps 4 sink tokens plus a sliding window, enabling 4M+ token streaming on Llama 2 7B with stable quality
- Mistral 7B's sliding-window inference relies on retaining early tokens, with vLLM and TGI implementing the recipe by default for long context
What an interviewer would ask next. Try answering before peeking at the approach.
QIf you re-train a model with a learned sink token at position 0, what changes downstream in the attention patterns?
Expect the sink role to concentrate on the dedicated token rather than scatter across the first few. Quality of long-context generation becomes more robust to small cache changes, since the sink position is fixed by design rather than emergent.
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 sink behavior as a bug to suppress, when it is an emergent consequence of softmax that production caches must accommodate or replicate.
60 second bullets to scan on the way to the call.
Why softmax forces a unit total over visible positions
Why early positions become the structural parking spot under causal masking
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.