LLM & Transformer Fundamentals·Question 46 of 109Advanced

What is "lost in the middle," and why doesn't a long context window equal reliable retrieval?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

"Lost in the middle" (Liu et al., 2023) is the empirical finding that models retrieve and use information best when it sits at the beginning or end of the context, with a pronounced accuracy dip for content in the middle - a U-shaped curve, demonstrated on multi-document QA and key-value retrieval tasks. Strikingly, this held even for models explicitly built for long contexts - extended-context variants were no better at using mid-context information than their short-context siblings at equal positions.

Full worked answer

"Lost in the middle" (Liu et al., 2023) is the empirical finding that models retrieve and use information best when it sits at the beginning or end of the context, with a pronounced accuracy dip for content in the middle - a U-shaped curve, demonstrated on multi-document QA and key-value retrieval tasks. Strikingly, this held even for models explicitly built for long contexts - extended-context variants were no better at using mid-context information than their short-context siblings at equal positions.

Why it happens (plausible mechanisms, worth presenting as such): training data has positional structure - important content clusters at document starts (headlines, abstracts) and recency matters for next-token prediction, so attention learns primacy and recency priors; attention mass also concentrates on early tokens ("attention sinks") and recent tokens by construction. Add causal masking's asymmetry and there's no pressure during pretraining to weight the middle of a 100k-token window uniformly.

Why long context ≠ retrieval - the engineering takeaways:

  • Advertised ≠ usable. A model accepting 1M tokens is not a promise of uniform recall over 1M tokens. Needle-in-a-haystack tests are the easy case (verbatim retrieval of a distinctive string); realistic tasks - aggregating several mid-context facts, reasoning across them, resisting distractors - degrade much earlier, which is what harder suites (RULER-style, multi-needle, long-form reasoning benchmarks) show.
  • RAG survives long context. Retrieval + curation puts the relevant 2k tokens where the model performs best, at a fraction of the prefill cost and latency of stuffing 500k tokens per query - quadratic prefill and per-token pricing make brute-force context economically dominated even when quality holds.
  • Position-aware prompting matters: put instructions and the most critical material at the start and end; re-state key constraints near the end for long agentic transcripts; summarise/compact long histories rather than letting them grow.

Going further: follow-up territory

Nuance for 2026: frontier models have substantially improved mid-context recall - the effect has shrunk, not vanished - and it remains worst on aggregation-style tasks. Verify against your own workload; don't assume either the 2023 pathology or vendor claims.

What a good answer covers

  • "Lost in the middle" (Liu et al., 2023) is the empirical finding that models retrieve and use…
  • Strikingly, this held even for models explicitly built for long contexts - extended-context variants…
  • Why it happens (plausible mechanisms, worth presenting as such)
  • Add causal masking's asymmetry and there's no pressure during pretraining to weight the middle of a…
  • Advertised ≠ usable

Key terms: beginning or end · Advertised ≠ usable · RAG survives long context · Position-aware prompting matters

Interviewer follow-ups to expect

  1. How would you design an eval for usable context length on your workload?

  2. Why do needle-in-a-haystack results overstate long-context ability?

  3. What are attention sinks and how do they connect?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep