Manuscript Offprint

arXiv:2611.04169

Length Is Cheap, Competition Is Not: Attention Predicts Context Rot in Retrieval

Yinuo Liu

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Why do language models fail on long inputs? The common answer is length. We show that, for retrieval, length is cheap and competition is not. On five open models (0.5B to 3B parameters, four families), neutral filler costs nothing: accuracy stays at 0.97 to 1.00, up to 32K tokens on Qwen2.5-1.5B. Statements in the format of the evidence, placed at the same positions, drop it to 0.11 to 0.21. A single statement that gives the queried key a rival value multiplies the loss by 9 to 110, and every additional rival adds to it. Inside the model, one quantity tracks the failure: the attention mass left on the evidence. Across 126,473 trials it explains up to 58% of the variance in loss; log length explains at most 8%. The masked-filler protocol behind the claim that length alone hurts reproduces on MMLU (11 to 18 points lost at 30K tokens), but fails a visible control in retrieval: masking costs 46 accuracy points at 32K tokens, while the same filler left visible costs none. In retrieval, context rot is a competition for attention. We release the probe and all 126K trial-level measurements.

Keywords: context rot, long-context language models, attention dilution, distractors, knowledge conflicts, needle in a haystack, retrieval-augmented generation.

Code github.com/yliusci/length-is-cheap

Data huggingface.co/datasets/yliusci/length-is-cheap

1 Introduction

Thirty-two thousand tokens of neutral text cost a 1.5B-parameter model nothing. A few sentences that contradict the evidence cost it most of its accuracy. This paper is about the gap between those two facts.

Language models now accept hundreds of thousands of tokens [1-7], yet they use far fewer [8-10]. Retrieval accuracy declines as inputs grow [8, 11-15], a degradation now called context rot [16, 17]. The prevailing explanation is length itself: Du et al. [18] hid the added tokens from attention, kept their positions, and still measured a loss. If length is the cause, the remedy is architectural, and every added token is a tax.

Length, however, never grows alone. Every added token is also added content, and in realistic inputs much of that content resembles what the model is looking for. Softmax attention [19] makes the distinction consequential. The weight on the evidence is

a∗=es∗es∗+∑j≠∗esj,a^{*}=\frac{e^{s^{*}}}{e^{s^{*}}+\sum_{j\neq*}e^{s_{j}}},

where s∗s^{*} is the attention score of the evidence and sjs_{j} the scores of all other keys. A thousand dissimilar tokens with low sjs_{j} add little to the denominator; a handful of near-copies of the evidence can halve a∗a^{*}. If this is what happens inside the model, context rot is a problem of competition, not of size, the remedy is to curate what enters the context, and a∗a^{*} should predict the loss better than length does.

We test this prediction directly. In a key-value retrieval task, we vary context length from 512 to 32K tokens, fill the same positions either with neutral material or with statements that share the format of the evidence, and measure on every trial both the log-probability of the correct answer and the attention mass a∗a^{*} that the model places on the evidence. We study five open models from 0.5B to 3B parameters from four families. Figure 1 summarizes the outcome: at equal length, the loss follows what the context contains and how much attention the evidence keeps, not how many tokens surround it.

Our contributions are:

  1. Length is cheap; competition is not. With neutral filler, accuracy stays between 0.97 and 1.00 on four of five models, up to 4K tokens on all four and up to 32K on Qwen2.5-1.5B. Filling the same positions with statements in the evidence template drives accuracy to 0.11 to 0.21 at 8K to 32K tokens. The loss concentrates on statements that give the queried key a rival value: one such statement multiplies the loss by 9 to 110, and the loss grows with their number at fixed length.

  2. Attention mass on the evidence predicts the loss. Across 126,473 trials on five models, log⁡(1/a∗)\log(1/a^{*}) explains 35 to 58% of the variance in loss, against 2 to 8% for log length, and the gap persists from 8K to 32K tokens.

  3. Masking is not a length baseline. Replicating the masked-filler protocol of Du et al. [18], MMLU accuracy falls by 11 to 18 points at 30K masked tokens on Llama-3.2-3B and Qwen2.5-7B. In retrieval, the same masking costs 46 points of accuracy at 32K tokens while the identical filler left visible costs none.

  4. An open probe. We release the harness, the attention probe, and all trial-level data: code at https://github.com/yliusci/length-is-cheap, data at https://huggingface.co/datasets/yliusci/length-is-cheap.

References (100)

Couldn't load all references. Reload the page to try again.