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

  1. In multi-document question answering, the relevant document is placed at different positions and accuracy measured by position.
  2. Accuracy usually traces a U-shaped curve: high at start and end, low in the middle.
  3. One explanation is that models' attention favours tokens at the start and end regardless of relevance.
  4. 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.

ON-PREMISES EXAMPLE

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.

Sources

In the glossary: Glossary, E to L

What does this term mean for your infrastructure?

We can work out together in a technical assessment how it maps onto your data, hardware and security requirements.

Request a technical assessment →

This site sets no cookies. Visitor numbers are counted in aggregate using a cookieless method that does not identify anyone. See the Privacy Policy for details.