Homeglossary

Lost in the Middle

Lost in the Middle is an LLM context-retrieval failure mode that causes a model to overlook important information placed near the center of a long prompt. It can produce incorrect answers even when the needed fact is present in the model's context window. The effect is a positional reliability issue, not proof that the model has forgotten or ignored every middle passage.

Build grounded AI apps with Emergent.

What is Lost in the Middle in AI?

Lost in the Middle is an LLM context-retrieval failure mode where a model overlooks important information placed near the center of a long prompt. The fact may be inside the context window, yet the model may not use it reliably when forming an answer. This positional bias has been documented in long-context language model research.

Why do LLMs get worse with more context?

Models often perform best when relevant evidence appears near the beginning or end of an input, creating a commonly observed U-shaped accuracy pattern. Long prompts also contain more distractions, repeated facts, and competing instructions. A context window defines how much text the model can accept, not how well it can retrieve every detail. Larger windows can therefore still experience context degradation, sometimes called context rot.

Lost in the Middle vs. text truncation

ProblemDid evidence enter the context?Best response
Lost in the MiddleYes, but its position reduces useCurate, reorder, and rerank context
Text truncationNo, input exceeded the limitShorten or split the input
HallucinationPossibly, but the answer is unsupportedRequire evidence and verify output
Poor retrievalUsually no relevant evidence was retrievedImprove search, chunking, and metadata

Where the effect causes software failures

The risk is highest when an application sends large, mixed collections of text to an LLM.

  • RAG search can miss the policy passage that answers a user question.
  • Long support chats can overlook an earlier account detail or constraint.
  • Codebase analysis can miss a dependency, security rule, or configuration file.
  • Agent tool logs can bury a failed command or API response.
  • Requirements documents can cause a generated feature to omit a key acceptance criterion.
  • Test generation can skip an edge case described deep in a specification.

How to test for Lost in the Middle

Use a position test rather than trusting a single successful prompt.

  1. Choose one question with a clear source fact.
  2. Keep the question and fact unchanged across test cases.
  3. Move the fact to the beginning, middle, and end of the context.
  4. Add realistic but irrelevant distractor material.
  5. Score answer correctness and whether the model cites the right evidence.

How to reduce Lost in the Middle in prompts and RAG

These practices reduce risk, but no prompt layout guarantees reliable retrieval.

  • Send only context relevant to the current question.
  • Chunk documents into focused, meaningful passages.
  • Use query-aware retrieval and reranking before generation.
  • Place essential instructions near prompt edges.
  • Provide structured summaries for long source collections.
  • Ask for evidence citations, then verify them after generation.

Lost in the Middle when building with Emergent

When building an AI feature, keep app requirements and supporting documentation focused, then test outputs against their source material. This is especially important for retrieval-backed search, coding tasks, and automated workflows. Explore related concepts in the Emergent glossary and apply them during app design and development. Build grounded AI apps with Emergent.

Start Building
on Emergent today
Start Building