Lost in the middle
Definition
The finding that language models use information at the start and end of a long context better than information buried in the middle.
In more detail
The name comes from a 2023 paper by Liu and colleagues, which showed that question-answering accuracy dropped when the relevant passage sat in the middle of many retrieved documents, producing a U-shaped curve. Newer long-context models have narrowed the gap, but position and clutter still affect recall.
The practical lessons are to send fewer, better documents rather than many, put the most relevant material and the instructions near the beginning or end, and rerank retrieved chunks so the best ones are not lost in a long list.
Related terms
Context rot
The gradual decline in a model's accuracy and instruction-following as its context fills up with long, stale or irrelevant content.
Context window
The maximum number of tokens a model can consider in one request, covering both the input you send and the output it writes.
Needle-in-a-haystack test
A long-context test that hides one fact in a large block of unrelated text and checks whether the model can find and repeat it.
Reranking
Re-scoring an initial set of retrieved results with a slower, more accurate model before passing only the best few on to the LLM.
Read more about Lost in the middle
- RAG fundamentals: retrieval before generation
What RAG is and how retrieval-augmented generation works, when it beats long context or fine-tuning, and a minimal working pipeline in about 80 lines of Python.
- Context engineering
Deciding what instructions, documents, tools and history a model sees at each step.
- RAG vs long context vs fine-tuning: how to choose
What each approach changes, what it costs, where it fails, and a practical order to try them in before you commit to one.