Lost in the Middle: An Emergent Property from Information Retrieval Demands in LLMs
Nikolaus Salvatore, Hao Wang, Qiong Zhang
TL;DR
This work reframes the lost-in-the-middle phenomenon in LLMs as an emergent adaptation to information retrieval demands during pre-training rather than a pure failure. By training GPT-2 and Llama models from scratch on simple human memory paradigms (Free Recall, Running Span) and a Masked Sequence Completion task, the authors show primacy arises under uniform long-term memory demand, recency under end-weighted short-term demand, and a canonical U-shaped pattern when both demands are present. They demonstrate that architectural biases (autoregressive processing) and attention dynamics (attention sinks) shape these effects, and that ablating sinks selectively disrupts long-term retrieval while leaving short-term performance relatively intact. The findings extend to sequence completion tasks, offering a unified account of positional biases as rational, task-driven adaptations with implications for mitigation and evaluation in LLMs. Overall, the paper links cognitive-inspired memory demands, transformer attention mechanics, and model architecture to explain and potentially control loss-of-middle effects in large language models.
Abstract
The performance of Large Language Models (LLMs) often degrades when crucial information is in the middle of a long context, a "lost-in-the-middle" phenomenon that mirrors the primacy and recency effects in human memory. We propose that this behavior is not simply a flaw indicative of information loss but an adaptation to different information retrieval demands during pre-training: some tasks require uniform recall across the entire input (a long-term memory demand), while others prioritize the most recent information (a short-term memory demand). Consistent with this view, we show that this U-shaped performance curve emerges when LLMs (GPT-2 and Llama variants) are trained from scratch on two simple human memory paradigms simulating long-term and short-term memory demands. Our analysis reveals that while the recency effect directly aligns with short-term memory demand in the training data, the primacy effect is induced by the uniform long-term memory demand and is additionally influenced by the model's autoregressive properties and the formation of attention sinks. Our main findings from simple human memory paradigms also generalize to a sequence completion task, which more closely resembles the next-token prediction process in LLM pre-training. Together, our findings reveal how information retrieval demands, model architecture, and structural attention dynamics during model training can jointly produce positional bias observed in LLMs.
