Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

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.

  • 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.