Rúben GalvãoThe Rabbit Hole

The Rabbit Hole / AI and machine learning / Language models / Inside attention

Attention sinks: where does unused attention go?

What could a token that appears in every sentence learn to contribute?

Something the sentence does not need to say

In “the old rabbit”, attention lets rabbit gather information from old. That contribution depends on the tokens in the sentence.

But what if the head could also learn a background contribution, available whatever the sentence says?

Imagine giving it an extra token that appears at the beginning of every context. Training could shape its key and value into something the head can always draw on.

A background contribution available in every contextTwo different contexts start with the same start token. The rabbit and carrot queries attend to it by different amounts. Its value vector stays the same; the attention weight scales its contribution.starttheoldrabbitrabbit can draw on the same start tokenstartaripecarrotcarrot can draw on the same start tokenStart's value58% attentionFor rabbit21% attentionFor carrotsame vectorA learned background; a context-dependent amount.
The same start token supplies the same value. Each query can take a different share of it.

Its value acts a little like a bias: a learned contribution that does not need to come from the sentence’s content.

The amount is still flexible. Different queries can give that same token different attention weights, taking more or less of its value.

A token that is always there

We already have a convenient token for this: the start marker. It is present before the sentence, and every later token can attend to it.

It cannot read the tokens that follow, so its representation can stay the same across different sentences. The model can learn to use it as that background contribution.

This also helps when the sentence has no useful answer to a head’s question. Softmax must still assign all its attention somewhere; the start token provides a familiar place to direct it.

This is an attention sink. In the map, it appears as a bright first column.

Where does the attention go?

Interactive

“Old” gives “rabbit” the adjective it was looking for.

Keys / answers →Queries / questions →startstartstart → start: 100%start → the: 0%start → old: 0%start → rabbit: 0%start → ate: 0%start → carrots: 0%thethethe → start: 58%the → the: 42%the → old: 0%the → rabbit: 0%the → ate: 0%the → carrots: 0%oldoldold → start: 30%old → the: 39%old → old: 31%old → rabbit: 0%old → ate: 0%old → carrots: 0%rabbitrabbitrabbit → start: 3%rabbit → the: 3%rabbit → old: 90%rabbit → rabbit: 3%rabbit → ate: 0%rabbit → carrots: 0%ateateate → start: 23%ate → the: 16%ate → old: 23%ate → rabbit: 16%ate → ate: 22%ate → carrots: 0%carrotscarrotscarrots → start: 15%carrots → the: 18%carrots → old: 16%carrots → rabbit: 17%carrots → ate: 17%carrots → carrots: 16%The rabbit row3%3%90%3%0%0%Each row adds up to 100%. Future tokens get 0%.

Compare No adjective with A sink pattern. Instead of mixing unrelated tokens, the head leans on the always-available start token.

A bright first column need not mean the start marker has an important meaning in the sentence. It can be doing this background job.

Then the window moves

In a sliding window, old tokens eventually leave the cache.

But when the start token leaves, we also remove a background contribution the head learned to rely on. Its attention is redistributed over the remaining tokens.

We could keep the first few tokens while the recent window moves on. That is the idea behind StreamingLLM.

Keep the start while the window moves

Interactive

The cache stays bounded: a small fixed beginning, plus the recent tokens. The middle still drops out; this does not preserve everything said earlier.

What if it contributes nothing?

The start token has a value the model can learn to use. Another design gives softmax an extra place to put attention, but deliberately supplies no background value.

Add a learned score alongside the token scores and pair it with a zero vector.

An extra softmax slot, with no token value behind itScores before softmaxQ · KQ · KQ · KlearnedSoftmax over all four scores6%thevalue vector5%rabbitvalue vector7%hopsvalue vector82%sinkzero value
The extra score takes a share of softmax, but contributes a zero vector to the weighted sum.

The weights for the actual tokens can now add up to less than one. The remaining share contributes nothing to the weighted sum.

That changes the attention calculation itself. There is another place we could intervene: after the head has collected its information. Could the model decide how much of that result to use?

Continue with attention gating.

Sources

The background diagram scales the same value vector by two attention weights calculated with softmax. The map calculates causal softmax rows. Its three views separate a useful match, a diffuse row, and a sink pattern. The window comparison gives both caches five slots. The extra-slot figure includes the sink in the softmax denominator and assigns it a zero value.

← Browse all subjectsBack to the beginning ↑