An attention sink is a token, typically the first token of a sequence, that absorbs a disproportionately large share of attention mass in an autoregressive transformer, largely independent of its semantic content. The phenomenon was named by Xiao et al. in the September 2023 StreamingLLM paper, which showed that preserving a few initial "sink" tokens stabilizes sliding-window inference over effectively unbounded streams.1 Learned variants of the mechanism later appeared in production architectures, including OpenAI's gpt-oss open-weight models.4

The sink is an emergent artifact of softmax normalization rather than a designed component: every attention head must distribute exactly one unit of mass across its context, and when no key deserves it, the excess has to go somewhere. Models learn to route that excess to the first tokens, and inference systems in turn learned to protect those tokens at all costs.

Role in the network

In the self-attention sublayer of each Transformer block, every query produces a probability distribution over the keys in its context and returns the corresponding weighted average of value vectors. Because the distribution is normalized, a head has no way to attend to nothing: even when no context token is relevant to the current query, the head must place its full unit of mass on some tokens.1

The first tokens of a sequence are the one constant available to absorb this excess. They are visible to every later position under causal masking, so models across families, including Llama 2 and Pythia, learn to place the surplus on them, making initial tokens function as a default no-op target for attention heads: mass parked there contributes a learned, effectively harmless value vector instead of corrupting the average with arbitrary content.1 Follow-up work by Sun et al. connected the behavior to "massive activations," a handful of hidden-state values that are orders of magnitude larger than the rest and act as fixed biases concentrating attention on the associated tokens.2

The practical consequence identified by StreamingLLM concerns long-context inference in large language models. Decoding keeps a key-value (KV) cache of past positions, and the cheapest way to bound it is a rolling window that evicts the oldest entries. A plain sliding window eventually evicts the initial tokens from the cache, and perplexity degrades sharply once the sinks disappear, because queries that learned to dump mass on token one suddenly find the dump missing. Keeping the cache entries of roughly four initial tokens alongside the recent window restored stable generation over millions of tokens without fine-tuning.1

The mathematics

For a query at position \(i\) with pre-softmax scores \(s_{i1}, \dots, s_{ii}\) over the keys in its context, the attention weights are

$$a_{ij} = \frac{\exp(s_{ij})}{\sum_{k=1}^{i} \exp(s_{ik})}, \qquad \sum_{j=1}^{i} a_{ij} = 1$$
Symbol Shape Meaning
\(s_{ij}\) scalar pre-softmax score of key \(j\) for the query at position \(i\)
\(a_{ij}\) scalar attention weight; nonnegative, and the weights of one query sum to 1
\(i\) scalar number of positions visible to the query under causal masking

Two properties of this map create the sink. The weights are positive and sum to one, so the head's output, the weighted sum \(\sum_j a_{ij} v_j\) of value vectors, is a convex combination: there is no "abstain" output. And the exponential is steep, so a modest learned preference concentrates most of the unit of mass on one key. A head that has nothing useful to do at a position minimizes harm by raising the score of a fixed, content-free key, and the first token is the only key guaranteed present in every training context.1

StreamingLLM's cache policy follows directly: with \(s\) sink tokens and a window of the \(w\) most recent tokens, the cache holds positions \(\{1, \dots, s\} \cup \{i - w + 1, \dots, i\}\), a total of \(s + w\) entries no matter how long the stream runs, and the paper found \(s = 4\) sufficient.1

Worked example: where the mass goes

Take one query attending to four keys. Key 1 is the first token of the sequence, which the model has learned to use as a sink, and carries score 2.0; keys 2 to 4 are content tokens, none of them relevant to this query, with scores 0.1, 0.0, and 0.2. The exponentials are \(e^{2.0} = 7.389\), \(e^{0.1} = 1.105\), \(e^{0.0} = 1.000\), and \(e^{0.2} = 1.221\), summing to 10.716, so the weights are

$$(a_{i1}, a_{i2}, a_{i3}, a_{i4}) = (0.690,\ 0.103,\ 0.093,\ 0.114)$$

that is, 69 percent of the mass parks on the semantically irrelevant first token, and the three content keys, whose scores span only 0.2, split most of the remainder almost evenly. Without the learned advantage the smear is worse: scores of (0.1, 0.1, 0.0, 0.2) give exponentials 1.105, 1.105, 1.000, 1.221 summing to 4.432 and weights (0.249, 0.249, 0.226, 0.276), a near-uniform average that dilutes the output with whatever happens to be in context. The sink collapses that smear onto one harmless address.

The matching cache layout, with 1 sink token and a window of 3: after token 6 the cache holds positions {1, 4, 5, 6}; after token 100 it holds {1, 98, 99, 100}. Four entries persist no matter how long the stream runs, and position 1 is never evicted, so the learned dump target is always present. A plain window of 4 would have evicted position 1 at step 5, which is exactly where StreamingLLM observes perplexity spike.1

Intuition

Read statistically, softmax forces each head to bet a fixed budget at every position, and the sink is where a head parks its budget when it has no opinion. The first token is a natural parking spot: it is present in every training context, so a head that learns to dump there receives a consistent gradient signal, and its value vector can be trained to contribute almost nothing to the output. The massive activations of Sun et al. give the mechanism a physical substrate: a few coordinates of the hidden state grow to extreme magnitudes and act as fixed biases that push the sink tokens' scores up regardless of their content.2

The phenomenon also resolves a puzzle about windowed inference. Sliding-window attention fails not because the model needs the distant past, but because it needs the first few tokens as an accounting device; once they are evicted, each head's budget is forced back onto ordinary keys and the output distribution degrades.1

Variants and extensions

Xiao et al. also proposed prepending a single dedicated, learnable sink token during pretraining, so that one placeholder absorbs the excess mass instead of several content tokens.1 A related line of work replaces sink tokens with a change to the attention function itself: adding a constant or learned term to the softmax denominator (informally, "off-by-one" or zero attention) lets a head attend to nothing at all.3 With an extra denominator term \(e^{b}\), the weights become

$$a_{ij} = \frac{\exp(s_{ij})}{e^{b} + \sum_{k=1}^{i} \exp(s_{ik})}$$

where \(b\) is a constant (\(b = 0\) in Miller's proposal, so the added term is exactly 1) or a learned per-head logit. Row sums can now fall below 1, and the missing mass is the amount the head chose not to allocate anywhere.3

Adoption

StreamingLLM's sink-plus-window cache was taken up for unbounded-stream inference, and it composes with paged cache managers: systems built on PagedAttention allocate cache blocks on demand, while a sink policy keeps the blocks holding the first tokens permanently resident.15

OpenAI's gpt-oss-120b and gpt-oss-20b, released in August 2025, adopt the denominator formulation: each attention head carries a learned per-head bias logit, described in the model card as similar to attention sinks and off-by-one attention, which the card says lets heads ignore all tokens. The design accompanies layers that alternate between dense and 128-token sliding-window attention.4 Attention sinks are also reported to matter for quantization and efficient attention kernels, since the associated outlier activations are sensitive to reduced precision.2

Limitations and critiques

A sink-plus-window cache stabilizes generation but is not long-range memory: content that scrolls out of the window is gone from the cache, so the method sustains an unbounded stream without extending what the model can recall from it.1 The phenomenon also couples model quality to inference numerics: the massive activations that implement sinks are exactly the outlier values that low-precision quantization handles worst, so aggressive weight or KV cache quantization can disturb sink behavior unless the scheme accounts for outliers.2 Finally, sinking is an emergent, learned artifact rather than a guaranteed one: its strength varies across heads and layers, and models that never develop clean sinks gain nothing from sink-preserving caches.1

History

The denominator idea predates the name. In July 2023, Evan Miller's "Attention Is Off By One" argued that softmax normalization should carry a constant term so that heads can abstain from attending.3 Two months later Xiao et al. published StreamingLLM, named the attention-sink phenomenon, traced the failure of window attention to the eviction of the initial tokens, and showed that retaining about four sink tokens sustains stable generation over millions of tokens.1 Sun et al. supplied the mechanistic account in February 2024, identifying massive activations as the biases that pin attention to sink tokens and linking them to quantization fragility.2 In August 2025, learned per-head sink logits shipped at scale in OpenAI's gpt-oss models, turning an emergent curiosity into a designed architectural component.4

See also

References


  1. Xiao, G., Tian, Y., Chen, B., Han, S., and Lewis, M., "Efficient Streaming Language Models with Attention Sinks," arXiv:2309.17453, September 2023. ↩↩↩↩↩↩↩↩↩↩↩↩↩

  2. Sun, M., et al., "Massive Activations in Large Language Models," arXiv:2402.17762, February 2024. ↩↩↩↩↩

  3. Miller, E., "Attention Is Off By One," July 2023. ↩↩↩

  4. OpenAI, "gpt-oss-120b & gpt-oss-20b Model Card," arXiv:2508.10925, August 2025. ↩↩↩

  5. Kwon, W., et al., "Efficient Memory Management for Large Language Model Serving with PagedAttention," arXiv:2309.06180, September 2023. ↩