Attention-sink and recency policies
Explain normalization-sensitive sink retention while separating stable streaming from access to omitted historical evidence.
On this page
The question for today
What you’ll understand
- Explain why removing an attended token can change the remaining normalization.
- Account for a fixed sink-plus-recency budget with distinct logical positions.
- Test task retention separately from streaming language-model stability.
StreamingLLM observes that retaining a few initial token states together with recent ones can stabilize streaming generation in its studied models. Those initial states can receive strong attention even when their text is not semantically informative. This does not imply that every old document remains available or that an arbitrary model needs the same number of sink tokens. The original paper explicitly distinguishes its streaming objective from extending long-term memory for long-document question answering.
Normalization gives a token more than one role
Softmax distributes weight across the available keys. A token with high attention score can absorb a large part of that mass even if its value does not supply the fact the current task needs. Removing it changes the denominator and the weights on the remaining entries. StreamingLLM presents evidence that some initial positions act as such sinks in the studied models. That finding does not make attention weights a general explanation of semantic importance, nor prove that initial words are the most useful evidence for every query.
A cache policy must preserve the required representation and position handling for the selected method. StreamingLLM discusses rolling-cache positions and rotary-key treatment; merely concatenating arbitrary old and recent KV tensors is not a full implementation of its recipe. Compare the actual implementation with its documented baseline and target architecture. A policy that stabilizes language-model perplexity can still fail a question whose only supporting record lies in the omitted middle. Evaluate the task being claimed, not just continuity of plausible text.
A fixed budget omits a potentially large middle
A simple sink-plus-recency policy keeps S initial slots and R recent slots, with overlap counted only once when the stream is short. After a sufficiently long stream, its direct capacity is S plus R regardless of how many tokens have been processed. This permits bounded retained-state storage, but it leaves many historical positions without direct KV access. External source storage and retrieval can offer another access path; they are additional system components, not information guaranteed by the sink policy itself.
The appropriate counts and behavior depend on the checkpoint and workload. A model trained with an explicit dedicated sink can differ from one that happens to use several initial tokens; hybrid attention layers can have other retention rules. Test sustained generation, precise old-fact recall, task reasoning, and source attribution separately. A headline about processing millions of streaming tokens must not be rewritten as a claim that millions of tokens are simultaneously accessible or that discarded middle evidence is preserved exactly.
Use separate quality and resource baselines
Compare recency-only, sink-plus-recency, and the legal full-history reference at matched conditions where feasible. Record which positions remain directly accessible and how source facts are selected for tests. Repeated references to a fact in the recent tail can make an old-fact test appear to succeed even when the original evidence was evicted. Use fresh synthetic values and checks that eliminate such shortcuts, while recognizing that a synthetic retrieval task does not cover every real long-document dependency.
The network lab illustrates a two-option logistic normalization only. Reset, set input to 1 and weight to 2.5, predict the fixed-bias logit and output, then Step: logit two gives approximately 0.8808. Compare a fresh Reset with both input at 1 and weight at 0.5 before Step: logit zero gives 0.5. This scalar unit has no cache or attention sinks and does not simulate removing a token from a trained model; it only shows sensitivity to a supplied logit difference.
Work it through
Removing a zero-valued entry changes a local mixture
Use three fixed attention logits (2,0,0) with scalar values (0,1,0). Treat the first entry as an illustrative sink. Compute the output before and after removing it while leaving the other logits and values fixed. This is a local toy operation, not a model-level prediction.
The denominator is e² + 2. The first weight is approximately 0.7870, while the second and third each have weight 1/(e² + 2), approximately 0.1065.
Only the second value is one, so the original scalar output is approximately 0.1065 despite the first entry having value zero.
After removing the first entry, the remaining equal logits give weights one half each, so output becomes 0.5. The result demonstrates normalization sensitivity without establishing that any particular language model requires this sink or retains old facts.
A token can influence attention normalization without carrying the queried fact in this toy value representation.
The living notebook
Explore the model
Interactive lab · network
A supplied logit difference changes a normalization
Reset, set x = 1 and w = 2.5, predict z = wx − 0.5, then Step: σ(2) ≈ 0.8808. Compare a fresh Reset with both x = 1 and w = 0.5 before Step: σ(0) = 0.5. This two-option logistic unit does not implement attention sinks, cache eviction, or a language model.
- Product · wx
- 1.2
- Logit · wx − 0.5
- 0.7
- Sigmoid output
- 0.6682
One inspectable sigmoid unit, σ(wx − 0.5). Playback traces the computation graph. There is no training, attention mechanism or hidden deep network. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forNormalization sensitivity is an algebraic effect; a streaming policy still needs its own state and quality tests.
Pause & reason
Check your understanding
Your turn
Try it yourself
A declared policy retains four initial slots and sixty recent slots after 1,000 tokens. Calculate retained slots, their fraction of processed positions, the recent one-based interval, and the number of directly omitted positions.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
The two sets no longer overlap at this stream length.
Compare with the solution
It retains 4 + 60 = 64 slots, or 6.4% of the 1,000 processed positions. Recent slots are 941 through 1,000; initial slots are one through four. Positions five through 940, totaling 936, lack direct entries. That percentage describes a storage policy, not a fraction of semantic facts remembered or a guarantee about exact recall.
Keep the idea
Take it with you
- Attention mass and semantic evidence importance are not identical.
- Sink-plus-recency storage remains a bounded selection of direct history.
- Stable streaming must be evaluated separately from old-fact access and long-document reasoning.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.