Document order and Lost-in-the-Middle tests
Vary evidence placement with matched content and actual token positions while controlling ordering semantics, truncation, and task shortcuts.
On this page
The question for today
What you’ll understand
- Design paired evidence-position tests without changing the intended answer.
- Report best/worst placement and paired outcomes rather than one length average.
- Separate observed position sensitivity from universal model-mechanism claims.
Lost in the Middle shows that changing relevant information’s position can substantially affect the studied models’ performance on particular tasks. The observation motivates controlled placement tests; it is not a law that every model and workload follows the same U-shaped curve. A useful experiment holds the required answer stable while measuring where the evidence actually appears after tokenization. Document number alone is an unreliable substitute when document lengths differ.
Move evidence without moving the goalposts
Use a set of order-independent records when the task permits reordering without changing meaning. Moving a paragraph inside a narrative can break references or chronology, changing the question rather than isolating a position effect. Keep the same supporting record, distractors, and answer policy across placements. Record the evidence span’s token offsets and the full prompt length under the actual tokenizer, including instructions and separators. A middle document can still occupy an early token position if other documents have unequal lengths.
Control truncation and output budgets explicitly. If a relevant source falls outside the accepted input after reordering, the result measures missing evidence rather than an internal position bias. Also inspect duplicate answer-bearing records in the distractors and accidental clues in document titles. Fresh random keys help reduce memorized-answer shortcuts, but an exact lookup is still narrower than comparing several documents or integrating a chain of facts. Use synthetic and natural task conditions as complementary evidence rather than treating one as proof of the other.
Describe the profile and its uncertainty
Report position-specific results and the range between the best and worst placement, not just a pooled mean. A strong average can hide a failure region that matters for the product. Compare model releases on the same base questions and inspect paired successes and failures. Uncertainty estimation should preserve question grouping across placements; counting each moved copy as an independent sample overstates the amount of evidence. Include several prompt templates when template sensitivity is part of the intended claim.
A U-shaped observed profile can motivate hypotheses about primacy, recency, attention, or training, but a performance curve alone does not identify its causal mechanism. Tokenization, query location, document ordering, and training overlap can all affect the comparison. The original study also distinguishes synthetic retrieval and multi-document QA behavior, so a prompt change that fixes one test need not fix another. State exactly which conditions improved before making a claim about general long-context robustness.
Keep the ordering policy in the deployed contract
Retrieval ranks, chronological sorting, grouping by source, or placing decisive passages near instructions can change final answer quality. Evaluate a proposed ordering policy on held-out questions and inspect whether it creates citation or chronology errors. If a policy uses a learned relevance score, include its own misses; an oracle placement that knows the answer is a diagnostic upper condition, not a deployable router. Preserve source identities when moving text so attribution remains testable and a later error can be traced to its visible evidence.
The function lab supplies a pure quadratic illustration only. Reset, set coefficient to 1 and position to −1, predict y, then Step: one. For a separate run, Reset and set both coefficient to 1 and position to 0 before Step: zero; repeat a fresh Reset with both coefficient 1 and position 1 to obtain one. These are values of y = ax², not measured language-model accuracies or a fitted Lost-in-the-Middle curve. The instrument does not reorder documents or test recall.
Work it through
A high pooled mean hides a middle-placement drop
The same 100 questions are each evaluated with supporting evidence at the beginning, middle, and end of matched contexts. Correct counts are 90, 60, and 85. Assume the desired answers remain unchanged and all evidence is visible. Compute the position profile and pooled mean.
Beginning accuracy is 90%, middle accuracy is 60%, and end accuracy is 85%. There are 300 runs but only 100 distinct base questions.
The placement gap is 0.90 − 0.60 = 0.30, or thirty percentage points. The end also exceeds the middle by twenty-five points.
Pooled accuracy is (90 + 60 + 85)/300 = 235/300, approximately 78.33%. That average hides the middle weakness, and uncertainty analysis should keep each question’s three outcomes grouped.
Position-resolved paired evidence is more informative than a single average or a universal U-shape claim.
The living notebook
Explore the model
Interactive lab · function
A quadratic illustration, not a measured position curve
Reset, set a = 1 and x = −1, predict y, then Step: one. Compare a fresh Reset with both a = 1 and x = 0 before Step: zero, then another fresh Reset with both a = 1 and x = 1 before Step: one. This is exactly y = ax², not an LLM accuracy fit or a document-order test.
- y at chosen x
- 0.608
- Tangent slope · 2ax
- 1.35
- Signed area · ax³/3
- 0.182
This lab uses only y = ax². Playback traces the curve within the fixed integration interval from 0 to x; it does not estimate numerical error or change the chosen point. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA position profile can vary across the domain; the actual profile must come from controlled task measurements.
Pause & reason
Check your understanding
Your turn
Try it yourself
Forty matched questions are evaluated at four positions, with correct counts 32, 30, 20, and 34. Compute position accuracies, best/worst gap, and pooled mean. Explain the independence issue.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
There are 160 runs but forty base questions.
Compare with the solution
The accuracies are 0.8, 0.75, 0.5, and 0.85. The gap is 0.85 − 0.5 = 0.35. Pooled mean is 116/160 = 0.725. The four outcomes for one question are related, so treating all 160 as independent questions can understate uncertainty. Grouped paired analysis and checks that reordering preserved answer meaning are needed before interpreting the profile.
Keep the idea
Take it with you
- Move evidence while preserving answer meaning, visibility, and token accounting.
- Report position profiles and group repeated placements by base question.
- An observed curve is task-specific evidence, not a universal mechanism or capability law.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.