Several mechanistic theories try to explain lost-in-the-middle. Show the strongest two, naming the model components involved.
The U shaped lost in the middle curve has two compounding mechanistic causes: attention sinks hoard softmax mass at the start, and RoPE relative position decay weakens long range pairs so the middle is doubly starved.
Imagine a long lecture hall where students raise hands to ask the teacher questions. By habit, the teacher always glances first at the people sitting closest to the door (sink seats). The teacher naturally pays the most attention to whoever just spoke (recency). The students in the middle rows raised their hands too, but they get squeezed out from both ends. The front gets attention by tradition, the back gets attention by proximity in time, and the middle just sits there waving. Lost in the middle is exactly that compounded squeeze, with the front being attention sinks and the back being recent tokens.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Lost in the middle is one of the most important empirical findings about long-context LLMs. It is also one of the most frequently invoked at the context engineering layer. Liu et al. (2023) plotted accuracy on multi-document question answering and key-value retrieval against the position of the relevant information in the prompt. The result was the well-known U shape: high accuracy at the start and end of the context, low in the middle.
The two strongest mechanistic explanations, attention sinks and RoPE relative position decay, both have empirical support and compound to produce the curve.
The empirical observation
The lost in the middle effect describes a position dependent accuracy curve on retrieval and reasoning over long contexts. The original experiment (Liu et al. 2023) used multi-document question answering. Place the one document that holds the answer at varying positions in a set of 10, 20 or 30 retrieved documents. Then ask the question and measure accuracy as a function of that document's position. A synthetic key-value retrieval task showed the same pattern.
The resulting curve is U shaped. Accuracy is highest when the relevant document is at the start or the end of the context and lowest in the middle. For GPT-3.5-Turbo, accuracy dropped by more than 20 points from the best position to the worst. In the 20- and 30-document settings, its worst case fell below its score with no documents at all.
Liu et al. found the shape in open models (MPT-30B-Instruct, LongChat-13B) and closed ones (GPT-3.5-Turbo, Claude-1.3), including models built for long context. Mitigations flatten the curve but rarely eliminate it. The question is what mechanism in the transformer produces this specific shape, and whether one mechanism is sufficient or both compound.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- StreamingLLM (Xiao et al. 2023) introduced the attention sink concept and showed that preserving the first few tokens greatly stabilizes long context inference.
- YaRN (Peng et al. 2023) extends RoPE's effective range via frequency rescaling plus an attention temperature. Qwen2.5 models enable it with a yarn rope_scaling entry for long inputs, while Llama 3.1 uses its own frequency-dependent scaling (rope_type: llama3).
What an interviewer would ask next. Try answering before peeking at the approach.
QIf you swap RoPE for ALiBi, do attention sinks still appear?
Yes. Attention sinks are a property of softmax conservation under weak query key matches, not a property of any specific positional encoding. The sink mechanism has been observed across encodings, including ALiBi based models. Switching the positional encoding changes the recency side of the curve (how recency decays) but does not eliminate the start of context advantage from sinks.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Blaming lost in the middle on a single cause (just RoPE, just attention sinks) without naming the compounding interaction between them.
60 second bullets to scan on the way to the call.
What lost in the middle means as an empirical observation
The attention sink mechanism and the softmax conservation argument
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.