FDEInterviews logo
★ Read firstTACL 2024

Lost in the Middle: How Language Models Use Long Contexts

The 2023 Stanford paper that showed models use evidence at the start and end of a long prompt far better than in the middle, sometimes worse than no evidence at all.

Breakdown by FDE Interviews · 11 min read · Updated

About the original · 2023
AUTHORS
Liu, Lin, Hewitt, Paranjape, et al.
FROM
Stanford University, UC Berkeley, Samaya AI
PUBLISHED
Jul 2023 · TACL 2024
CITED BY
5,537Semantic Scholar · Oct 2026
IN THIS BREAKDOWN · 10 SECTIONS

You can read 19% of this breakdown.

01

The paper in one minute

By 2023 language models accepted 16,000, then 100,000 tokens of input, and the natural move was to give them more: more retrieved documents, longer chat histories, whole contracts. The authors asked a simple question nobody had measured carefully. Does a model use everything in its context equally well?

They built a test where only one thing changes. A question from Natural Questions comes with 10, 20 or 30 Wikipedia passages; exactly one contains the answer, and the others are relevant-looking distractors from a search engine. They move the answer passage from first to last and measure accuracy at each position, across six models including GPT-3.5-Turbo and Claude-1.3, plus their extended-context versions.

Every model showed the same shape: a U. Accuracy was highest when the answer was in the first passage, recovered somewhat when it was last, and sagged in the middle. For GPT-3.5-Turbo with 20 passages, accuracy fell from 75.8% at the start to 53.8% in the middle. With no passages at all, answering from memory, the same model scored 56.1%. Burying the answer in the middle was worse than giving the model nothing.

Two more findings complete the picture. The 16K and 100K versions of each model did no better than the 4K and 8K versions when the input fit both. And in a realistic retrieval setup, going from 20 to 50 retrieved passages added only about 1.5 points while making the prompt two and a half times longer.

THE IDEA, VISUALLY
ACCURACY BY WHERE THE ANSWER SITS, GPT-3.5-TURBO, 20 PASSAGES Appendix Table 6 40% 50% 60% 70% 80% 90% no passages at all: 56.1% only the answer passage: 88.3% 75.8 57.2 53.8 55.4 63.2 1st 5th 10th 15th 20th position of the passage with the answer WHAT THE CURVE MEANS Start of the prompt: best place for evidence. Middle of 20 passages: worse than giving the model nothing. End of the prompt: second best. More is not better 50 passages instead of 20 added about 1.5 points for GPT-3.5-Turbo while the prompt grew 2.5x.
Where the evidence sits changes the answer. Accuracy is highest when the right passage comes first, recovers somewhat at the end, and sags in the middle below the no-evidence baseline.
Research notes: the problem, approach and results
75.8% → 53.8%

GPT-3.5-Turbo's accuracy with the answer passage first, against in the middle of 20

56.1%

its accuracy with no passages at all, higher than with the answer buried mid-prompt

+1.5points

from sending 50 retrieved passages instead of 20

THE PROBLEM

Context windows grew to 16K, 100K tokens and beyond, and teams started filling them, assuming the model reads all of it equally well.

THE IDEA

Hold everything fixed except where the relevant passage sits in a long prompt, and measure accuracy at each position.

THE RESULT

A U-shaped curve in every model tested: best at the start, good at the end, worst in the middle. Longer-context versions were no better at using their context.

02

Why it matters to an FDE

"The model has a million-token window, so just put everything in" is one of the most common requests on enterprise projects. This paper is the evidence for why that is a design decision, not a free win.

Position is a variable you control. A model's accuracy on the same evidence moved by 20 points depending only on where the evidence sat. Your prompt template decides positions: system instructions first, retrieved passages in some order, history, then the question. Put the most important material at the start or end, and keep the question near the evidence.

More context can lower accuracy. Every extra passage pushes the useful ones further from the edges and gives the model more to sort through. The retrieval experiment shows retrieval recall still climbing at 50 documents while model accuracy had already flattened. Past a point you pay more for tokens and latency and get nothing back.

Bigger windows did not mean better reading. Extended-context models matched their shorter siblings. A larger window raises the ceiling on what you can send; it does not improve how well the model uses what you send. Test long-context claims on the customer's data, with the evidence deliberately placed in the middle.

THE FULL BREAKDOWN

Understand the mechanism. Try it on a real problem.

Unlock this breakdown and 49 more papers.

Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.

6 months · One payment · No auto-renewal

Get Premium · ₹2,000 / $25
  • ◇1 architecture diagram
  • </>1 runnable code experiment
  • ▦4 results tables
  • ?5 interview questions with answers
  1. 03Key takeaways

    The ideas to keep, the experiment's design, the results by context size and the misreadings to avoid

    Free account
  2. 04How it works

    Both experiments, the controls that make them trustworthy, and the analysis of why the curve appears

    Premium
  3. 05The numbers that matter

    The baselines, the curves, the extended-context comparison and the retrieval study, with sources

    Premium
  4. 06Try it yourself

    Use the paper's own curves to decide between more passages, fewer passages and a reranker

    Premium
  5. 07Where it breaks

    What the study cannot tell you, and how much has changed since 2023

    Premium
  6. 08Using it on a deployment

    Prompt layout rules, context budgets and the position test to run before launch

    Premium
  7. 09Interview angles

    Five questions this paper prepares you for, with answer hints

    Premium
Back to the paper library →