SinkTrack: Attention Sink based Context Anchoring for Large Language Models
Organizations: The State Key Lab of Brain-Machine Intelligence, Zhejiang University
Abstract
Large language models (LLMs) suffer from hallucination and context forgetting. Prior studies suggest that attention drift is a primary cause of these problems, where LLMs' focus shifts towards newly generated tokens and away from the initial input context. To counteract this, we make use of a related, intrinsic characteristic of LLMs: attention sink -- the tendency to consistently allocate high attention to the very first token (i.e., <BOS>) of a sequence. Concretely, we propose an advanced context anchoring method, SinkTrack, which treats <BOS> as an information anchor and injects key contextual features (such as those derived from the input image or instruction) into its representation. As such, LLM remains anchored to the initial input context throughout the entire generation process. SinkTrack is training-free, plug-and-play, and introduces negligible inference overhead. Experiments demonstrate that SinkTrack mitigates hallucination and context forgetting across both textual (e.g., +21.6% on SQuAD2.0 with Llama3.1-8B-Instruct) and multi-modal (e.g., +22.8% on M3CoT with Qwen2.5-VL-7B-Instruct) tasks. Its consistent gains across different architectures and scales underscore the robustness and generalizability. We also analyze its underlying working mechanism from the perspective of information delivery. Our source code is available at https://github.com/67L1/SinkTrack.
Figures & tables
| Method | Acc (%) |
| CoT (Baseline) | 43.83 |
| Inject Every Layer | 51.02 |
| Inject Every 5 Layers | 60.04 |
| Intermittent & Increasing | 59.87 |
| Intermittent & Decaying | 60.69 |
Appendix figures & tables3 assets
Supplementary material from the paper’s appendix.
Appendix
| Gen. Idx | Seq. Pos | Attn to BOS | Max Attn (Others) | Ratio |
| 1 | 8083 | 0.561 | 0.057 | 9.87x |
| 64 | 8146 | 0.570 | 0.048 | 11.97x |
| 128 | 8210 | 0.612 | 0.054 | 11.25x |
| 256 | 8338 | 0.560 | 0.050 | 11.24x |
| 512 | 8594 | 0.558 | 0.037 | 15.17x |
| 1024 | 9106 | 0.582 | 0.042 | 13.96x |
| Model | w/o Injection | w/ Injection | Overhead |
| Llama3.1-8B | 35.90 ms | 36.66 ms | +0.76 ms |
| Qwen2.5-VL-7B | 107.13 ms | 110.26 ms | +3.13 ms |
LLM Context Management
Large language model context management studies how to select, compress, retrieve, and organize information within bounded model inputs.
See all 248 papers