Zenaique

Describe the attention sink: why token 0 hoards attention mass

Flashcard·Easy·4.0 · 0·~30s·Asked atDeepseekRobinhoodTuring
Attempt it
TL;DR

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.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

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.

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.

αij=exp(sij)kiexp(sik)\alpha_{ij} = \frac{\exp(s_{ij})}{\sum_{k \le i} \exp(s_{ik})}

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.

What sink mass actually does in the network
Why sliding-window inference breaks the sink
Production approaches and learnable sinks
How to reason about sinks during model debugging
Putting numbers to it: 2026 frontier-model context
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

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
Sign in to see more production examples.

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?
A

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.

1 more follow-up an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Treating sink behavior as a bug to suppress, when it is an emergent consequence of softmax that production caches must accommodate or replicate.

Sign in to see all red flags and common mistakes.

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

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Explain scaled dot product attention.
Short answer·Medium