Skip to content

Context Rot: How Increasing Input Tokens Impacts LLM Performance

Skip →MLA (DeepSeek-V2 latent attention)
LLM stage 2 #4corefrontierblogrubric 10/122025 · ~35 min

Kelly Hong, Anton Troynikov, Jeff Huber

Status

TL;DR. Earlier long-context benchmarks usually make tasks harder as inputs get longer, so they cannot isolate length itself. Chroma’s report holds the task fixed and varies only input length, across 18 LLMs. Performance always degrades, but non-uniformly. It falls faster when the needle matches the question less closely or when distractors are present, and it is worse on coherent haystacks than on shuffled ones. On LongMemEval, an oracle-focused ~300-token prompt (built from the dataset’s evidence labels) beats the ~113k-token full history for every model.

Why it matters now. Frontier windows are often treated as a reason to skip retrieval: “just put everything in the prompt”. This report argues the opposite with controlled experiments. Its conclusion, which it calls context engineering (deciding carefully what goes into the window and how), is essentially retrieval, reranking and filtering under another name. For an IR researcher this is the cleanest current argument that retrieval quality still matters when the reader has a million-token window. It also shows that the IR notion of hard negatives (non-relevant passages that look relevant to the query) is exactly what hurts long-context readers.

Fix a task (find a needle, answer a question, or copy text) and measure accuracy Am(L)A_m(L) of model mm as only the input length LL changes. Each NIAH configuration is run at 8 lengths × 11 needle positions, at temperature 0 where allowed. The manipulated factors are measured with embeddings averaged over five models f1,…,f5f_1,\dots,f_5:

sim(n,q)=15∑e=15cos⁡(fe(n),fe(q)),sim(n,H)=15∑e=1515∑c∈top5e(n,H)cos⁡(fe(n),fe(c)),\text{sim}(n, q) = \frac{1}{5}\sum_{e=1}^{5} \cos\big(f_e(n), f_e(q)\big), \qquad \text{sim}(n, H) = \frac{1}{5}\sum_{e=1}^{5} \frac{1}{5}\sum_{c \in \text{top5}_e(n, H)} \cos\big(f_e(n), f_e(c)\big),

where nn is the needle, qq the question and HH the haystack chunks. The main finding is that the slope ∂Am/∂L\partial A_m/\partial L is not a property of the model alone. It is steeper when sim(n,q)\text{sim}(n,q) is low and when distractors are present, and it depends on haystack content and structure.

The repeated-words task removes retrieval entirely. The model must copy a list of up to 10,000 identical words containing one different word. Outputs are scored by normalized Levenshtein distance. One common normalisation is 1−Lev(y^,y)/max⁡(∣y^∣,∣y∣)1 - \text{Lev}(\hat y, y)/\max(|\hat y|, |y|); the report does not spell out its normaliser.

Context rot: the same task gets harder as input grows, and the content of the context matters Left: four factors that Chroma held fixed or varied while only the input length grew. Lower needle-question similarity makes performance fall faster. Distractors that look like the answer hurt, and some distractors hurt more than others. Needle-haystack similarity has a non-uniform effect. Shuffled haystacks beat logically coherent ones. Right top: on LongMemEval, a focused prompt of about 300 tokens beats the full prompt of about 113,000 tokens that contains the same evidence. Right bottom: the takeaway for retrieval pipelines is context engineering: retrieve, rerank and trim, rather than paste everything into a long window. Hold the task fixed, grow the input 1. Needle–question similarity less lexical/semantic overlap → faster decline 2. Distractors one hurts, four hurt more; not all distractors equal 3. Needle–haystack similarity effect is non-uniform across models and settings 4. Haystack structure shuffled sentences beat a coherent essay 18 models, 8 lengths × 11 needle positions, temperature 0, 194,480 calls; GPT-4.1 as the judge. LongMemEval focused (~300 tokens) full (~113k tokens) same evidence; focused wins clearly (bar length = input size, not score) Takeaway for RAG a long window is not a free pass; retrieve → rerank → trim, then put only what is needed in the prompt (Chroma calls this context engineering)
Original sketch. The four NIAH factors the report varies, the LongMemEval focused-versus-full comparison (bar length shows input size, not score), and the takeaway for retrieval pipelines.
  • Scale: 18 models, including thinking modes where available. Qwen models are extended from 32,768 to 131,072 tokens with YaRN. Refusals occur in 69 of 194,480 calls (0.035%).
  • Needle–question similarity ranges from 0.445 to 0.775 (PG essays) and 0.521 to 0.829 (arXiv). Lower-similarity pairs degrade faster with length.
  • Needle–haystack similarity: in the PG haystack, PG needles score 0.529 and arXiv needles 0.368, and arXiv needles do significantly better. In the arXiv haystack the differences are minimal.
  • Haystack structure: shuffled beats original for all 18 models. The authors call this surprising.
  • LongMemEval: 306 prompts remain after removing 38 ambiguous ones, covering knowledge update, temporal reasoning and multi-session questions. Focused prompts (~300 tokens) are derived from the dataset’s original labels plus manual adjustments, so they are an oracle-evidence intervention, not a tested retriever. Every model is significantly better on the focused version. Claude shows the biggest gap, mostly from abstentions.
  • Repeated words: 1090 variations per word pair across 12 lengths from 25 to 10,000 words. Models start inserting words absent from the input, typically from around 500–750 words in the Gemini family, and some outputs degenerate or refuse.
  • This is an industry report, not peer-reviewed, from a retrieval-infrastructure company. The code is released, but independent replication is the real test.
  • The materials are small and hand-written (needles, four distractors, two haystack topics). The authors say two topics are not enough to generalise the needle–haystack result.
  • It gives no mechanism: why coherence hurts and why similarity changes the slope are left to interpretability. The authors also expect real tasks (synthesis, multi-step reasoning) to degrade more.
  • An LLM judge (GPT-4.1) does the scoring, and per-cell uncertainty is not reported on the page.
  • Open: how the slope depends on the retrieval distribution of non-relevant context. Are random, BM25 and dense negatives increasingly harmful? This is the question that would turn the findings into reranker cut-off rules.
  • Open: whether long-context training on hard-negative haystacks can flatten the curve, or whether trimming will always win.

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    The report makes 194,480 LLM calls and sees 69 refusals, and its LongMemEval comparison uses full prompts averaging about 113k tokens against focused prompts of about 300 tokens. (a) Check the stated refusal rate. (b) For a hypothetical GQA model with 32 layers, 8 KV heads, head dimension 128 and a 16-bit KV cache, compute the KV-cache size per token and for each prompt type. (c) Give the ratios of KV memory and of attention-score FLOPs between full and focused prompts, and say what this means for the cost of skipping retrieval.

    What a strong answer covers
    • (a) 69 / 194,480 ≈ 3.55 × 10⁻⁴ ≈ 0.035%, as reported, so refusals cannot explain the degradation curves.
    • (b) Per token: 2 (K and V) × 32 layers × 8 heads × 128 dims × 2 bytes = 131,072 bytes = 128 KiB.
    • Full prompt: 113,000 × 128 KiB ≈ 14.8 GB (about 13.8 GiB) per sequence; focused prompt: 300 × 128 KiB ≈ 39 MB.
    • (c) Length ratio ≈ 113,000 / 300 ≈ 377, so KV memory and linear (projection/MLP) prefill cost scale about 377×; the QKᵀ score computation scales with length squared, about 377² ≈ 1.4 × 10⁵×.
    • The report shows the long prompt is also less accurate than the oracle-focused one for every model, so stuffing the window costs more and reads worse. A real retriever adds its own cost and evidence misses, so retrieval is a cost and a quality decision at once, not a guaranteed win.
  2. Mechanism

    Explain the three NIAH-style findings on needle–question similarity, needle–haystack similarity and haystack structure. For each, say how the report measures the factor, what it found, and give a plausible (clearly labelled as speculative) account of why. Which finding contradicts the authors' own prior expectation?

    What a strong answer covers
    • Needle–question similarity: cosine similarity averaged over five embedding models (PG essays 0.445–0.775, arXiv 0.521–0.829, std below 0.1). Lower similarity makes performance fall faster with length. Speculation: a near-literal match can be found by a sharp attention lookup, while a latent match requires spreading relevance computation over many more positions, which gets harder as the context grows.
    • Needle–haystack similarity: mean cosine of the needle's top-5 haystack chunks, averaged over five embedders (e.g. PG needles 0.529 vs arXiv needles 0.368 in the PG haystack). In the PG haystack, the out-of-topic arXiv needles do significantly better; in the arXiv haystack the difference is minimal, so the effect is non-uniform.
    • Haystack structure: original coherent essays vs sentence-shuffled haystacks of the same topic. Across all 18 models, shuffled is consistently better.
    • The authors expected the opposite: a needle should stand out more in coherent text because it breaks the logical flow. They call the result surprising and leave the mechanism to interpretability work.
    • Speculative account: coherent text invites the model to track a discourse across long spans, so attention is spent on structure; shuffled text has little exploitable structure, so the out-of-place needle is easier to single out. This is a hypothesis, not a finding.
  3. What if…

    Describe the distractor ablation (conditions, needle choice, and what changes with length). What do the failure analyses show about how different model families fail, and how does the same behaviour reappear in LongMemEval? Why does it matter which failure mode a RAG system's reader has?

    What a strong answer covers
    • Setup: a high-similarity needle–question pair (so the baseline is easy) with four hand-written distractors; conditions are needle only, needle plus one randomly placed distractor, and needle plus all four.
    • One distractor already lowers accuracy and four lower it further; the impact grows with input length and is not uniform across distractors (in the arXiv-haystack/PG-needle setting distractor 3 hurts most; distractors 2 and 3 appear most in hallucinated answers).
    • Claude models hallucinate least (Sonnet 4 and Opus 4 tend to abstain, saying no answer can be found); GPT models hallucinate most, giving confident wrong answers.
    • In LongMemEval, Claude shows the largest focused-vs-full gap, which the report attributes largely to abstentions under ambiguity.
    • For RAG, abstention is recoverable (retrieve again, ask the user) while a confident wrong answer propagates; an accuracy-only metric scores both the same, so evaluation should separate them.
  4. Critique

    Critique Context Rot as evidence for the claim that long windows should be filled carefully. Consider the publication venue and author incentives, the judge, the scale of hand-written materials, the two-topic design, and its critique of NoLiMa. What would make you trust the conclusions more?

    What a strong answer covers
    • It is a company technical report, not peer-reviewed, from Chroma, a retrieval/vector-database company whose product benefits from the conclusion that context should be retrieved and trimmed. The code release helps offset this.
    • Scoring relies on an aligned GPT-4.1 judge (reported >99% agreement with humans); judge errors could correlate with output length or abstention style.
    • Needles, questions and distractors are hand-written and few; the needle–haystack result rests on two topics, which the authors say is insufficient to generalise.
    • The report notes 72.4% of NoLiMa needle–question pairs need external world knowledge, so NoLiMa mixes non-lexical matching with knowledge recall. A fair point, but Context Rot's own similarity manipulation is via embedding cosine, which is a proxy for lexical-plus-semantic overlap rather than a clean variable.
    • The authors admit they do not explain mechanisms and that tasks are simple. More trust would come from independent replication, confidence intervals per cell, and realistic RAG prompts with qrels instead of synthetic needles.
  5. Design

    Design a context-engineering pipeline for a RAG or deep-research agent that applies the report's findings, under a hypothetical deployment constraint: p95 answer latency of 5 s and a reader prompt of at most 8k tokens. Specify how you choose what enters the prompt, its order and length, and how you treat near-miss passages. Evaluate end to end against both the oracle-focused prompt (a ceiling) and the full-history baseline, charging retrieval latency and evidence misses to your pipeline.

    What a strong answer covers
    • Retrieve broadly (hybrid sparse + dense), then rerank with a cross-encoder or LLM reranker and keep a small, relevance-thresholded set, aiming toward the focused-prompt regime rather than the full-history one, knowing a real retriever will not reach the oracle.
    • Treat high-similarity non-relevant passages as distractors (hard negatives): deduplicate near-duplicates, drop passages that match the query topic but not the answer, and prefer passages with direct evidence.
    • For agents, compact or summarise old turns and tool outputs instead of appending them; LongMemEval shows that an oracle-focused ~300-token memory beats ~113k tokens of raw history, so the gap is an upper bound on what compaction can recover.
    • Choose the budget empirically: sweep prompt length with fixed evidence (padding with retrieved near-misses, not random text) and pick the knee of the accuracy curve for your reader model.
    • Evaluate answer accuracy, abstention rate and hallucination rate separately, plus retrieval recall of the evidence, so you know whether failures come from retrieval or from reading. Report the pipeline between the two anchors: full history (floor) and oracle-focused (ceiling), with latency and token cost per query.
  6. Research idea

    Propose a study that turns Context Rot's synthetic findings into an IR experiment: does the similarity of the non-relevant context to the query (random text vs BM25 negatives vs dense-retriever negatives) change how fast reader accuracy decays with length? Give the hypothesis, data, conditions, controls and metrics.

    What a strong answer covers
    • Hypothesis: padding with harder negatives (higher query similarity) makes accuracy fall faster with length than random padding, mirroring the distractor results, and dense negatives hurt more than BM25 ones.
    • Data: a QA or RAG test collection with relevance judgements (e.g. TREC-RAG style qrels or a BEIR-style dataset with answers), so the gold evidence is known and fixed.
    • Conditions: gold evidence held constant; pad to fixed lengths (e.g. 1k to 128k) with random corpus passages, BM25 top-ranked non-relevant passages, or dense top-ranked non-relevant passages; also vary gold position and coherent vs shuffled ordering.
    • Controls: several reader models, temperature 0, multiple seeds for padding samples; check that “non-relevant” negatives are truly non-relevant (unjudged passages can be false negatives).
    • Metrics: answer accuracy, abstention and hallucination rates, and the slope of accuracy vs log length per condition; the output is a guideline for reranker cut-offs.

Done with this page?

Status