Lost in the Middle: How Language Models Use Long Contexts
By Nelson F. Liu, Kevin Lin, John Hewitt, Ashwin Paranjape, Michele Bevilacqua, Fabio Petroni, Percy Liang. 2023
4,355 citations recorded by the source corpus.
While recent language models have the ability to take long contexts as input, relatively little is known about how well they use longer context. We analyze the performance of language models on two tasks that require identifying relevant information in their input contexts: multi-document question answering and key-value retrieval. We find that performance can degrade significantly when changing the position of relevant information, indicating that current language models do not robustly make use of information in long input contexts. In particular, we observe that performance is often highest when relevant information occurs at the beginning or end of the input context, and significantly degrades when models must access relevant information in the middle of long contexts, even for explicitly long-context models. Our analysis provides a better understanding of how language models use their input context and provides new evaluation protocols for future long-context language models.
Subfields: Artificial Intelligence, Computer Vision and Pattern Recognition, Large Language Models, Prompting & Reasoning
How researchers see this paper
The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.
In Artificial Intelligence
- Mohit Bansal
- Jianfeng Gao
- Luke S. Zettlemoyer
- Quoc V. Le
- Yoshua Bengio
- Kyunghyun Cho
- Percy Liang
- Caiming Xiong
In Computer Vision and Pattern Recognition
- Luc Van Gool
- Dacheng Tao
- Ming-Hsuan Yang
- Trevor Darrell
- Xiaogang Wang
- Jitendra Malik
- Andrew Zisserman
- Alan L. Yuille
In Large Language Models
- Xiao Liu
- Julian McAuley
- Ion Stoica
- Naman Jain
- Canwen Xu
- Tianjun Zhang
- Aleksandra Piktus
- Matei A. Zaharia
In Prompting & Reasoning
- Matei A. Zaharia
- Mohit Bansal
- Patrick Lewis
- Donald Metzler
- Xiao Liu
- Sheng Shen
- Tim Rocktaschel
- Arash Vahdat
Citations in the corpus
- Code Llama: Open Foundation Models for Code (2023, background): “Liu et al. (2023b) showed that the inability to recall content placed in the middle of long prompts is a common failure mode in LLMs; our retrieval task is analogous to their setup, albeit tailored to code models which are not fine-tuned to follow instructions.”
- Large Language Models for Information Retrieval: A Survey (2023, neutral): “With the rapid development of the above reader approaches, many researchers have begun to analyze the characteristics of retrieval-augmented LLMs: • Liu et al. [195] find that the position of the relevant/golden reference has significant influences on the final generation performance.”
- Evaluating Very Long-Term Conversational Memory of LLM Agents (2024, background): “…process (Mallen et al., 2023; Gao et al., 2023b; Liu et al., 2023b); (2) Challenges arise in reasoning over retrieved documents, especially when the model struggles to identify the correct context among the retrieved data (Liu et al., 2023a); (3) Reasoning over time intervals presents challenges.”
- A Survey on the Memory Mechanism of Large Language Model-based Agents (2024, neutral): “Moreover, these methods also have the problem of lost in the middle [96], leading to position bias.”
- RAGAs: Automated Evaluation of Retrieval Augmented Generation (2023, background): “Moreover, when context passages are too long, LLMs are often less effective in exploiting that context, especially for information that is provided in the middle of the context passage (Liu et al., 2023).”
- Evaluating Large Language Models in Class-Level Code Generation (2024, background): “As revealed by the recent work [47], LLMs often become substantially less effective with the increasing length of inputs; and in particular they tend to make better usage of the information located at the beginning or end of the inputs than that in the middle of inputs.”
- Retrieval-Augmented Generation for Large Language Models: A Survey (2023, background): “A notable issue, termed the “lost in the middle” phenomenon, arises when a single retrieval yields redundant content that may dilute or contradict essential information, thereby degrading the generation quality [ Liu et al. , 2023a ] .”
- LLMs Get Lost In Multi-Turn Conversation (2025, neutral): “This finding mirrors findings of a loss-in-the-middle phenomena of LLMs paying more attention to documents at the start or end of their provided context, at the cost of middle-context content [29, 50, 40].”
- Benchmarking Retrieval-Augmented Generation for Medicine (2024, background): “Liu et al. (2023) found the RAG performance is lowest when the relevant information is placed in the middle, a phenomenon known as “lost-in-the-middle”.”
- LongMemEval: Benchmarking Chat Assistants on Long-Term Interactive Memory (2024, neutral): “Although the retrieval accuracy can be enhanced through the preceding designs, it does not guarantee that the LLM can effectively reason over the extensive context (Shi et al., 2023; Liu et al., 2024).”
- From Local to Global: A Graph RAG Approach to Query-Focused Summarization (2024, background): “Longer text chunks require fewer LLM calls for such extraction, but suffer from the recall degradation of longer LLM context windows (Kuratov et al., 2024; Liu et al., 2023).”
- TravelPlanner: A Benchmark for Real-World Planning with Language Agents (2024, methodology): “We envision TravelPlanner as a catalyst for future research, aiming to enhance agents’ performance in increasingly complex scenarios, hill-climbing towards human-level cognitive capabilities.”
- GenSLMs: Genome-scale language models reveal SARS-CoV-2 evolutionary dynamics (2022, methodology): “The inputs to GenSLM are nucleotide sequences, encoded at the codon level (every three nucleotide represents a codon; hence the 20 natural amino acid language is described by 64 codons).”
- Evaluation and mitigation of the limitations of large language models in clinical decision-making (2024, neutral): “The sensitivity of LLMs to the order of presented information has been well documented on multiple-choice questions 45,46 and information retrieval 47 .”
- Long-context LLMs Struggle with Long In-context Learning (2024, neutral): “Nonetheless, there are studies indicating that longer input prompts can actually diminish performance (Liu et al., 2023), with the effectiveness of prior large language models (LLMs) being constrained by the maximum sequence length encountered during their training.”
- Graph Retrieval-Augmented Generation: A Survey (2024, neutral): “The development of Large Language Models like GPT-4 [ 116 ],”
- MLVU: A Comprehensive Benchmark for Multi-Task Long Video Understanding (2024, neutral): “Needle-In-the-Haystack-Search (NIHS) is a popular evaluation task for long-context LLM [26].”