Lost in the middle

The search does its job perfectly. The answer is wrong anyway.

"It retrieves the right document and still gets the answer wrong."

A real example

The system was prompted and the golden chunk, the one I'd recorded in advance as holding the answer, was retrieved. Here's the result:

What is the calibration code for the Vega-7 probe?

NOT IN CONTEXT

This was staged on purpose so that the 'lost in the middle' issue can be fully illustrated. The answer passage was moved through the pile, first to last, with everything else remaining in place, it's the only way to show the effects of the passage moving between the start and the end, while displaying the effects of the middle.

Find a setting that works

Below are two sliders: how many passages the model was given, and where the answer sat in the pile. Drag either one. Every combination is real, with the actual passage and answer behind it.

71,402 of 202,752 tokens the model can hold - 35.2% of the window

0 tokens202,752 tokens (everything this model can hold)
startmiddleend

100% at the start, 100% at the end, and as low as 20% at 67% through.

Found in 2 of 10 attempts (20%)

The passage placed at this position

The Vega-7 orbiter was inserted into a polar survey orbit following a single mid-course correction, and its instrument suite was brought online over the following eleven days. Ground controllers assign every survey platform a calibration code used to reconcile telemetry across mission phases, and the calibration code for the Vega-7 probe is XQ-4417. Subsequent passes returned atmospheric density profiles consistent with earlier modelling, though the upper-altitude readings showed a seasonal variation that had not been predicted. The survey continued for a further two years before the platform was placed into a reduced-power mode, with periodic contacts maintained from the deep space network throughout.

  1. foundXQ-4417
  2. missedNOT IN CONTEXT
  3. missedNOT IN CONTEXT
  4. foundThe calibration code for the Vega-7 probe is XQ-4417.
  5. missedNOT IN CONTEXT
  6. missedNOT IN CONTEXT
  7. missedNOT IN CONTEXT
  8. missedNOT IN CONTEXT
  9. missedNOT IN CONTEXT
  10. missedNOT IN CONTEXT
Full written explanation
Symptom
"It retrieves the right document and still gets the answer wrong."
What's happening
The model is shown many passages at once, including the one with the answer. It reads the start and the end carefully and skims the middle. A long enough pile can bury the answer where it lands, even though it's there.
The check
Move the same passage to the start or end of an otherwise identical pile. If the answer is now found, the fault was never in search: it returned the same passage the whole time.
The fix, and its cost
Order the assembled context so likely answers sit near the edges, or reduce how much text is sent at once. Both trade some system flexibility, or completeness, for reliability.
What doesn't work
Retrieving more results, reranking, or a better embedding model. None of these touch what happens to a passage after it has already been correctly found.