Define the lost-in-the-middle effect and the empirical pattern it describes
lost-in-the-middle names the U-shaped accuracy curve LLMs show across context position: good at the start, good at the end, weak in the middle.
Imagine handing a friend a 50-page printed report and asking, somewhere in there is one paragraph about Tuesday's meeting, what did it say? Most people will skim the first few pages, flip to the last few pages, and shrug at the middle. Their attention is naturally pulled to the edges. Long-context language models behave the same way. Drop the answer in the first page or the last page and they nail it. Bury it on page 25 of 50 and they often miss it, even though every word was right there in front of them. The curve of their hit rate against where the answer sits looks like a U: high on the left, low in the middle, high on the right.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Long context windows feel like the obvious answer to retrieval failure: just put everything in. lost-in-the-middle is the result that broke that hope. A 2023 study moved a single gold passage through positions 1 to 20 of a retrieval-augmented QA prompt and measured how often the model produced the right answer. The curve was not flat and it was not monotonic. It was a U.
The finding survived replication, model upgrades, and a generation of long-context training tricks. In 2026, with Claude Opus 4.7, GPT-5.5, and Gemini 3.1 Pro all sporting hundred thousand token plus windows, the U is still there. The window grew. The position bias did not go away.
This card walks through what the effect is, why it matters for context engineering, and what you do about it.
The U-curve in one figure
The Liu et al. 2023 setup is small enough to hold in your head. Take an open-book QA question. Build a 20-document context where 19 are distractors and 1 is the gold passage that actually contains the answer. Run the same model, same question, same documents, but slide the gold passage through each of the 20 positions. Measure exact-match accuracy at each position.
The resulting curve has a characteristic shape. Position 1 is high. Position 20 is high. The middle positions, roughly 8 through 14, dip noticeably. Plot it and the line forms a wide U.
Why the shape matters more than the number
The shape, not the absolute height, is the diagnostic. Models with stronger absolute recall raise the whole curve, but the dip remains. The U-curve says context position is itself a feature the model is using, whether you intended it as one or not.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- Liu et al. 2023, Lost in the Middle: How Language Models Use Long Contexts. The paper that named the effect on a 20-document retrieval QA setup.
- RULER (Hsieh et al. 2024) extends needle-in-a-haystack to multi-needle and multi-hop variants; midcontext positions still underperform on Claude Opus 4.7 and GPT-5.5 in 2026 runs.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy does increasing the context window from 32k to 200k not flatten the curve?
Bigger windows widen the interior; the head and tail bias is architectural, not capacity-bound. Cite RULER and BABILong 2026 numbers.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Assuming a bigger context window fixes it. Frontier 2026 models with 200k-plus windows still show the U-curve on RULER and BABILong.
60 second bullets to scan on the way to the call.
Define lost-in-the-middle in one sentence
Sketch the U-curve and label primacy versus recency
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.