Retrieval Quality at Context Limit

algorithm 2511.05850
long-contextneedle-in-a-haystackevaluationlost-in-the-middleretrieval

§1 TL;DR #

Gemini 2.5 Flash retrieves 26/26 single-needle factoids at 100% accuracy across all context-fill ratios (13%–92% of 1M-token limit), empirically demonstrating the "Lost in the Middle" U-curve has vanished for simple factoid Q&A at frontier model scale.

§2 Q1 / Q2 / Q3 #

Q1 痛点 #

Liu et al. (2023) showed that LLMs (GPT-3.5, Llama-2) exhibit a U-shaped retrieval accuracy curve — high recall at the start and end of the context, but severe degradation (~55%) in the middle. This "Lost in the Middle" (LITM) effect shaped the entire RAG ecosystem: practitioners chunked documents and retrieved small relevant subsets rather than trusting the model to find facts anywhere in a long context. With 2025-era models claiming 1M+ token windows, the question is whether LITM persists at this scale.

Q2 方法 #

The paper proposes a controlled evaluation protocol:

Before (Liu et al. 2023)After (this paper)
Models with 4K–32K context (GPT-3.5, Llama-2)Model with 1M context (Gemini 2.5 Flash)
Multi-document NQ-based datasetSingle corpus (Friends transcript, 924K words) with 20 injected non-canon factoid snippets
Vary question position relative to evidenceFix questions at end, vary evidence position across full context via equidistant injection
Per-question independent callsSingle batched call with all 26 questions + full context
No ablation for training-data leakageAblation: same questions without injection confirm model cannot answer from memory

核心技术壁垒: Not in the paper itself (which is a measurement study), but in the model under test — Google's NIAH-curated training curriculum that explicitly trains on long-context retrieval tasks during pre-training/annealing, making the model robust to all positions. The paper's own barrier is the clean measurement protocol (API-cap verification via HTTP 400 + per-needle ablation + LLM-judge + manual review).

Q3 结果 #

§3 架构 / 方法图 #

Figure 2: Experimental pipeline showing Friends transcript injection and single-batch query protocol

Figure 2: Experimental design schematic.

The experiment pipeline consists of: (1) the Friends TV transcript (924K words, >1M Gemini tokens) trimmed to ratio $r \in \{0.1, 0.2, \ldots, 0.8\}$; (2) 20 non-canon dialogue snippets injected equidistantly across the trimmed slice; (3) a single batched prompt containing the full context followed by all 26 questions; (4) submission to Gemini 2.5 Flash (T=0.1, thinking disabled, no system instructions); (5) answers judged by a fresh Gemini 2.5 Flash instance + manual review. The 80% ratio triggers HTTP 400, which simultaneously validates the exact context cap at 1,048,576 tokens.

flowchart LR A["Friends transcript\n924K words"] --> B["Trim to ratio r"] B --> C["Inject 20 needles\nequidistant"] C --> D["Single batched prompt\n(context + 26 Qs)"] D --> E{"Gemini 2.5 Flash\nT=0.1, thinking off"} E -->|"HTTP 200"| F["Judge + manual verify\n→ 26/26 correct"] E -->|"HTTP 400"| G["Context limit located:\n1,048,576 tokens"]

§4 作者证明 #

无形式化作者证明 — 仅实证

This paper contains no theorems, lemmas, proofs, convergence bounds, or formal loss functions. It is a purely empirical measurement study. The "proof" is the experimental result itself (Table I: perfect accuracy at all ratios).

What kind of guarantee would have been desirable:

6 minimum checks (all trivially satisfied or N/A for this paper type):

#CheckStatus
1Theorem statement reproduced?N/A — no theorem
2Assumptions listed?N/A — no formal assumptions
3Proof sketch?N/A — no proof
4Bound tightness discussed?N/A — no bound
5When do assumptions break?N/A
6Loss decomposition?N/A — no loss function

§5 实验与数据 #

5.1 Main Result: Accuracy vs Context Ratio #

Figure 1: Accuracy vs context-fill ratio showing flat 100% for Gemini 2.5 Flash contrasted with the 2023 LITM U-curve

Figure 1: Accuracy vs. context-fill ratio (derived from Table I data).

The blue line shows Gemini 2.5 Flash achieving 26/26 at every ratio from 0.13× to 0.92× of the context limit — a perfectly flat line at 100%. The gray dashed curve represents the schematic 2023 LITM U-shape from Liu et al. (GPT-3.5/Llama-2, ~55% at center). The contrast is stark: a ~45-percentage-point gap in the middle has been entirely closed. The red marker at ratio 0.8 denotes the HTTP 400 rejection point.

5.2 Context Budget Breakdown #

Figure 3: Pie chart showing effective vs nominal context budget decomposition

Figure 3: Effective context budget breakdown.

This figure decomposes the context budget into three regimes: (1) the successfully used portion (≤70% of corpus, ~0.97M tokens, representing 0.92× of the 1,048,576 cap); (2) a narrow headroom buffer (~75K tokens between the largest successful run and the hard cap); (3) the rejection regime (≥80% of corpus, 1.05M tokens). The largest successful test leaves only ~7% headroom before the API rejects — demonstrating that the 100% accuracy persists even at near-saturation of the context window.

5.3 Table I (reproduced verbatim) #

Ratio of full transcriptRatio of context limitQuestions correctAccuracy
0.10.13261.0
0.20.26261.0
0.30.40261.0
0.40.53261.0
0.50.66261.0
0.60.79261.0
0.70.92261.0
0.81.05N/AN/A

The accuracy column is degenerate — all 1.0 until rejection. The paper's result is precisely this degeneracy: there is no interpolatable degradation curve. Either the model handles the context perfectly or the request is rejected outright.

5.4 Dataset & Evaluation Design #

PropertyValue
CorpusFriends TV transcript (Kaggle)
Corpus size924K words (>1M Gemini tokens)
Needles injected20 non-canon dialogue snippets
Questions26 (1–2 per needle)
Needle placementEquidistant (one at start, one at end)
Context sizes tested7 ratios (0.1–0.7 of full corpus)
ModelGemini 2.5 Flash
Temperature0.1
ThinkingDisabled
System promptNone
JudgeFresh Gemini 2.5 Flash + manual review
AblationPer-needle verification (query without injection → "unknown")

5.5 Dataset Analysis #

§6 论证链 #

StepPremiseConclusionLoad-bearing?
1Liu et al. 2023 showed LITM (U-shaped accuracy curve at ~55% in the middle) on GPT-3.5/Llama-2 with ≤32K context; this became the foundational justification for chunked RAGLITM was the accepted model of long-context retrieval failure (2023–2024 consensus)Yes — establishes the phenomenon being revisited
22025 frontier LLMs (Gemini 2.5 Flash, Claude 4, GPT-4.1) claim 1M+ token windows; Gemini 1.5 report explicitly mentions NIAH-style training dataLITM may no longer hold at frontier scale — needs empirical re-evaluationYes — motivates the experiment
3Controlled experiment: Friends corpus (924K words), 20 equidistant non-canon needles (26 Q&A), single batched call, T=0.1, ablation verifies no training-data leakageThe measurement isolates context-length effect on single-needle retrieval with controlled confoundersYes — experimental validity
47 ratios tested (0.13×–0.92× of context limit), all return 26/26 correct; 0.8 ratio (1.05× limit) triggers HTTP 400 confirming true cap = 1,048,576 tokensLITM is absent for single-needle factoid Q&A in Gemini 2.5 Flash up to its full context windowYes — main empirical finding
5Paper cites multi-needle (LangChain 2024), multi-hop (HELMET 2025), multimodal (Vaidya 2025) benchmarks that still report degradationThe LITM disappearance does NOT generalize beyond single-needle; harder tasks remain open problemsYes — scope limitation (prevents over-claiming)

§7 实现 cross-reference #

[实现未公开]

No source code, scripts, prompts, or evaluation harness is released. The methodology is described textually in §II with sufficient detail for replication (corpus source: Kaggle Friends transcript; YAML Q&A format shown in Appendix B Listing 1; API parameters: T=0.1, thinking off, no system prompt). The paper does not cite or link any GitHub repository.

关键实现细节 (easy-to-miss from the methodology):

  1. Single batched call: All 26 questions are submitted in one prompt alongside the full context — this is not 26 separate API calls. Cross-question attention and prefix-caching behavior are part of the measured result (questions always sit in the recency-bias zone at prompt end).
    1. Context limit discovery via HTTP 400: Rather than estimating the true token limit from documentation, the author uses the API's rejection message ("input token count (1105498) exceeds maximum (1048576)") as a precise measurement instrument — a cheap trick that pins the cap to the exact token.
    2. Reproducibility & Ecosystem #

      • Training code open? N/A — this is an evaluation paper, not a training paper. The model (Gemini 2.5 Flash) is closed-weight.
      • Evaluation code open? No. Closest open reference for NIAH evaluation: LangChain's multi-needle framework, HELMET benchmark code (ICLR 2025).
      • Community replication? Not documented. The experiment is trivially reproducible (~$1–2 in API costs, single afternoon) but no independent replication report is cited.
      • Which models/systems use this finding? The result supports the "stuff everything in context" strategy used by Gemini-based applications (NotebookLM, Google AI Studio). RAG designers for frontier-model systems can cite this to justify skipping retrieval for simple single-fact lookup over long documents.