Lost-in-the-middle produces a U-shaped accuracy curve: models attend reliably to the start (primacy) and the end (recency) of a long context but skip content placed in the interior.
Imagine a teacher reading a long list of names and later asking which names were on it. Students remember the first few (they were paying full attention at the start) and the last few (those are still ringing in their ears). The middle names get fuzzy. Language models do something similar with long context: the names at the start and end stick, the names in the middle blur. Plot what they remember against where the name was in the list, and you get a U-shape: high on both ends, low in the middle. The trick for context engineering is to put the important stuff where the U is high, not where the U is low.
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.
The lost-in-the-middle effect is one of the most robust empirical findings in long-context language modeling. It says that retrieval and reasoning accuracy depend on where the target content sits in the context window, with the dependence taking a U-shape: high at the start (primacy), low in the middle, high at the end (recency). This deep dive walks through the original finding, the attention-mechanism intuitions that explain the shape, the 2024-2026 replications on frontier models, and the context-engineering moves that exploit the curve rather than fighting it.
The original finding: Liu et al. (2023)
Nelson Liu and collaborators published "Lost in the Middle: How Language Models Use Long Contexts" in July 2023, and the paper introduced both the name and the curve shape that the field now treats as canonical.
The setup was multi-document question answering. Given a query and 10, 20, or 30 retrieved Wikipedia paragraphs, one of which contained the answer, the question was: does the model's ability to use the answer-containing paragraph depend on where that paragraph sits in the input?
The answer was yes, and the dependence had a striking shape. When the gold paragraph was at position 1 (first), accuracy was around 75%. When it was at the last position, accuracy was around 70%. When it was in the middle (position 5 out of 10), accuracy dropped to around 50%. Plotting accuracy against position produced a clear U-curve.
The finding was not specific to one model. Liu et al. tested GPT-3.5, GPT-4, Claude 1.3, MPT-30B, and LongChat-13B. All five showed the U-shape, with varying depths. The conclusion was that lost-in-the-middle is a structural property of how decoder transformers attend over long context, not an artifact of any one model's training.
The paper also showed the effect on key-value retrieval (find the value associated with a key in a JSON-like input). Here too the U-curve appeared, and here too it was robust across models. The structural story was strong enough that the finding immediately became a default assumption in long-context prompt engineering.
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 paper plotted the original U-curve on multi-document QA
- RULER (NVIDIA, 2024) replicated the U-shape across modern long-context models at varying lengths
What an interviewer would ask next. Try answering before peeking at the approach.
QWhat does an inverted U-shape look like, and when do you see it in practice?
An inverted U is high in the middle and low at the ends. You rarely see it in language-model retrieval. The closest analog is a model trained heavily on the middle of long contexts (e.g., book continuation), but even there primacy and recency still dominate. The inverted U is mostly a distractor option in multiple choice.
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.
Expecting accuracy to decay monotonically with position and missing that the start is also a privileged location, not just the end.
60 second bullets to scan on the way to the call.
State that the lost-in-the-middle curve is U-shaped
Identify primacy and recency as the two high regions
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.