An attention sink is a token position, most often the first token of the sequence, that receives a disproportionately large share of attention weight in a transformer even though its content carries little or no semantic information. In large language models, the phenomenon appears in most layers and heads after the first few, and it has practical consequences for streaming inference, KV cache eviction and quantization.
The effect was characterized in detail in the StreamingLLM work of 2023, which showed that removing the initial tokens from the cache causes perplexity to collapse, while keeping only four initial tokens restores stable generation. Since then, attention sinks have become a standard consideration in the design of long-context and memory-efficient inference systems.
Why attention sinks form in transformers
Attention sinks form because the softmax function forces attention weights to sum to one. When a query does not need information from any particular key, the head still has to place its probability mass somewhere. Training discovers that a consistently visible position is the cheapest place to dump that unused mass, and in a decoder-only model with causal masking the first token is the only position that every later query can see.
Over training, the model learns to give the sink token a key vector that aligns with many queries, while its value vector stays close to zero or points in a harmless direction. The result is a no-op attention pattern: the head attends heavily to the sink, but the sink contributes almost nothing to the residual stream. This is closely linked to massive activations, a small number of hidden-state dimensions with values orders of magnitude larger than the rest, which tend to appear at the sink position.
The following table summarizes the main ingredients that researchers associate with sink formation.
| Factor | Role in sink formation | Observable sign |
|---|---|---|
| Softmax normalization | Forces weights to sum to one, so surplus mass needs a target | Large weight on one fixed position |
| Causal masking | Makes the first token visible to every query | Sink almost always at position zero |
| Massive activations | Create extreme key norms at the sink position | Outlier values in a few hidden dimensions |
| Near-zero value vectors | Keep the sink from altering the output | High attention, low contribution |
| Pretraining scale | Gives the model time to settle on a stable dump target | Sinks emerge early and persist |
Where attention sinks appear and how strong they are
Attention sinks are nearly universal in pretrained decoder-only models, but their strength varies by layer, head and architecture. The first one or two layers usually attend locally and show weak sinks, whereas middle and late layers often assign well over half of the attention mass to the first token in many heads. The exact share depends on the model and the input, so published figures should be read as ranges rather than constants.
Sinks do not depend on the specific token. If the beginning-of-sequence token is replaced by an ordinary word such as a newline, the model still treats whatever occupies position zero as the sink. Some models also develop secondary sinks at delimiter tokens, punctuation or the start of a new turn in a chat template.
The table below lists typical locations of sinks and how they usually behave.
| Location | Typical strength | Notes |
|---|---|---|
| First token of the sequence | Strong in most mid and late layers | The classic sink, independent of token identity |
| Beginning-of-sequence token | Strong when always present | Becomes the designated sink in training |
| Delimiter or newline tokens | Moderate | Secondary sinks in some models |
| Special turn markers | Variable | Appear in chat-tuned models |
| Learned sink token | Strong by design | Added deliberately during pretraining |
Attention sinks in streaming and long-context inference
The most practical consequence of attention sinks concerns sliding-window KV caches. A simple window that keeps only the most recent tokens eventually evicts the first token, and once the sink disappears, the softmax redistributes its mass onto meaningful tokens, which destabilizes every later layer. Perplexity then rises sharply, and generation often degenerates into repetition or nonsense.
StreamingLLM solves this by always retaining a few initial tokens alongside a rolling window of recent tokens. Positions are assigned within the cache rather than in the original text, which keeps positional encodings such as rotary position embedding consistent. This allows stable generation over millions of tokens with a fixed memory budget, although the model still cannot recall content that has been evicted from the window.
The comparison below shows how cache strategies interact with attention sinks.
| Strategy | Memory use | Effect on quality |
|---|---|---|
| Full KV cache | Grows linearly with length | Stable but limited by memory |
| Plain sliding window | Fixed | Collapses once the sink is evicted |
| Sliding window with recomputation | Fixed, high compute cost | Stable but slow |
| Window plus retained sink tokens | Fixed | Stable fluency, no recall of evicted text |
| Heavy-hitter eviction | Fixed | Keeps sinks automatically because of high scores |
Effects on quantization and interpretability
Attention sinks are tied to activation outliers, which make low-bit quantization harder. When a few channels at the sink position carry extremely large values, uniform quantization ranges become too wide and precision is lost for ordinary tokens. Methods such as outlier-aware or rotation-based quantization partly exist to manage this problem.
For interpretability, sinks are a frequent source of misleading attention maps. A heat map that shows most attention going to the first token does not mean the model relies on that token for meaning. Analysts therefore discount the sink or examine value-weighted attention, which multiplies weights by the norm of the corresponding value vectors.
Designing models with explicit sinks
Because sinks emerge anyway, some architectures provide them deliberately. Options include a dedicated learnable sink token prepended during pretraining, a learnable bias added to the softmax denominator, and variants sometimes called softmax-plus-one or off-by-one softmax that let a head attend to nothing. Gated attention, which multiplies the head output by a learned gate, can also reduce the need for a sink.
Each option shifts the trade-off between simplicity, stability and outlier size. A designated sink keeps the familiar architecture while making streaming safer; denominator changes can shrink massive activations, which helps quantization; gating adds parameters but gives heads a direct way to stay silent.
| Approach | Main benefit | Main cost |
|---|---|---|
| Learnable sink token | Predictable sink for streaming | Must be included in pretraining |
| Softmax with extra denominator term | Heads can attend to nothing | Changes standard attention kernels |
| Gated attention output | Smaller outliers, cleaner heads | Extra parameters and compute |
| No special handling | Standard architecture | Implicit sinks and activation outliers |
Common misconceptions about attention sinks
- Sinks are not a bug in the data. They arise from the attention mechanism itself and appear across datasets and model families.
- The first token is not semantically important. High attention to it reflects a parking strategy, not reliance on its meaning.
- Retaining sinks does not extend memory. It keeps generation fluent, but evicted content is still unavailable.
- Sinks are not limited to text. Vision transformers show similar behavior through high-norm register-like tokens.
Understanding it simply
Each part of a language model must split its attention across earlier words. The shares must always add up to one hundred percent. Sometimes no earlier word is useful. The model still has to put that attention somewhere.
So the model learns a habit. It sends the spare attention to the very first word, which it can always see. That word works like a parking spot for unused attention. It does not add meaning to the answer.
This matters when a system drops old words to save memory. If the parking spot is removed, the attention spills onto real words and the output breaks down. Keeping the first few words prevents that problem.
Applied in practice
A team running a customer-support assistant needs it to handle conversations that last many hours without restarting. Their open-weight model has a context window of 8,192 tokens, and memory on the serving GPU is limited, so they adopt a sliding-window KV cache of 4,096 recent tokens.
In early tests, replies remain fluent until the conversation passes about 4,100 tokens, then quality collapses into repeated phrases. The engineers trace the failure to the eviction of the first token, which had served as the attention sink in most layers.
They change the cache policy to always keep the first four tokens plus the 4,092 most recent ones. Perplexity on long transcripts returns to the level seen within the window, memory use stays fixed, and the assistant runs for more than 200,000 tokens of dialogue without degradation. The team documents that older details still fall out of the window, so they add a separate summary step for long sessions.