What is lost in the middle?
Lost in the middle is the phenomenon where language models perform best when relevant information sits at the start or end of a long context and markedly worse when it is in the middle; it appears even in models trained for long context.
Context window size states how many tokens a model can take; lost in the middle shows how well it uses them. A needle-in-a-haystack test measures the problem by placing information at different positions.
- Topic
- Prompts, context, reasoning and generation
- Also known as
- Positional bias
- Origin
- Liu et al., 2023
How lost in the middle works
- In multi-document question answering, the relevant document is placed at different positions and accuracy measured by position.
- Accuracy usually traces a U-shaped curve: high at start and end, low in the middle.
- One explanation is that models' attention favours tokens at the start and end regardless of relevance.
- Mitigations put the most relevant pieces first or last, shorten context or correct the attention bias.
In more detail
Saturation of simple needle tests and the risk that remains
Most frontier and modern open-weight models score near 100% on simple single-needle NIAH tests, creating a false sense of security. However, lost-in-the-middle degradation still resurfaces in multi-hop reasoning, conflicting-evidence synthesis and noisy multi-document RAG, as demonstrated by newer benchmarks such as RULER, NoLiMa and LongBench v2.
Likely causes: attention sinks and RoPE recency bias
U-shaped attention bias is thought to stem from both architectural mechanics and data or positional priors: models allocate disproportionate attention to initial tokens as 'attention sinks' (primacy bias) and to the newest tokens near the query (recency bias) due to RoPE relative-distance decay and causal masking.
Further mitigations: context compression and map-reduce processing
Beyond reranking (placing top chunks at the start and end, known as sandwich ordering), teams reduce lost-in-the-middle errors through context compression (extracting only query-relevant sentences before generation), map-reduce summarisation across document batches and citation verification checks.
Why lost in the middle matters for on-premises AI
In RAG systems the order of retrieved chunks affects answer quality: a key chunk left mid-list can be missed. The study defining the phenomenon showed accuracy drops markedly when the position of relevant information changes, even in long-context models. A later study tied it to U-shaped attention bias and reported up to 15 points better RAG performance with a calibration correcting it. Adding more documents to context does not always mean better answers.
A law firm's contract search assistant reranks its retrieved chunks and places the most relevant at the start and end of the context; it measures the accuracy difference on the same questions by varying chunk order.
Common questions
Does lost in the middle affect long-context models?
Yes. Even models trained for long context can use middle information worse than the start and end.
How is it reduced in a RAG system?
By retrieving fewer but more relevant chunks, reranking so the most relevant come first and last and testing by position.
Related terms
- Context window
- Long-context model
- Needle-in-a-haystack test
- Context compression
- Reranking
- Conversation history
Sources
- Liu et al., Lost in the Middle: How Language Models Use Long Contexts, 2023
- Hsieh et al., Found in the Middle: Calibrating Positional Attention Bias Improves Long Context Utilization, 2024
In the glossary: Glossary, E to L