Paper notes

Lost in the Middle: Models Use the Start and End of a Long Context Best

Liu et al. (2023) moved the answer around inside long inputs and found a U-shaped curve: accuracy is highest at the start or end and lowest in the middle. With 20 documents GPT-3.5-Turbo loses 22.0 points between its best and worst position. This post recomputes the results and discusses RAG.

Published Updated 25 min read

On this page
  1. Why this paper matters
  2. Main contributions
  3. Experimental design: only move the evidence
  4. Multi-document question answering
  5. Key-value retrieval
  6. The models
  7. Two baselines: closed-book and oracle
  8. Result 1: the U-shaped curve
  9. Recomputing it
  10. Beyond position: the cost of the distractors themselves
  11. Result 2: key-value retrieval, where even exact matching fails
  12. Why it happens: three preliminary analyses
  13. Case study: is it worth stuffing in more documents
  14. Robustness checks: is the finding an artifact of the setup
  15. What it means for RAG and prompt design
  16. Limitations and cautions when reading
  17. What to take away from this paper
  18. Further reading
  19. FAQ

Why this paper matters

When long-context models are announced, the headline is usually the window: 4K, 32K, even 100K tokens. In July 2023, Liu et al. (Stanford University, UC Berkeley and Samaya AI) asked a plainer question: does a model that can fit the text actually use it? They ran two controlled experiments in which only the position of the relevant information in the input changes, and got a U-shaped curve: models do best when the relevant information is at the very beginning or the very end of the input, and worst when it is in the middle. The effect also appears in models built explicitly for long contexts. The paper was published in TACL; this post cites version 3 on arXiv, dated 20 November 2023.

It is an evaluation paper: it proposes no new model and does not pin down the cause. Its weight comes from two things. First, it offers a clean evaluation protocol: to claim that a model robustly uses a long context, show that moving the evidence somewhere else barely changes the score. Second, its numbers are enough to retire the assumption that “retrieved” means “used”, which changed how RAG systems assemble their context.

Four numbers are worth remembering. All of them come from the paper, and the recomputation follows below.

  • In 20-document multi-document QA, GPT-3.5-Turbo scores 75.8% when the answer document is first and 53.8% when it is tenth, a gap of 22.0 points. At the tenth position it is 2.3 points below its closed-book score with no documents at all (56.1%).
  • The longer-window variants (GPT-3.5-Turbo 16K, Claude-1.3 100K) differ from the original versions by at most 0.3 points at the same position: a longer window did not make the models better at using their context.
  • Placing the question both before and after the data makes key-value retrieval nearly perfect, but does not clearly improve multi-document QA.
  • Going from 20 to 50 retrieved documents raises GPT-3.5-Turbo’s accuracy by only about 1.5 points, and Claude-1.3’s by about 1 point.

Main contributions

  1. An evaluation protocol. Two tasks: multi-document QA, which resembles RAG, and a synthetic key-value retrieval task that removes semantics and tests exact retrieval. Each time only the position of the relevant information or the length of the input changes.
  2. A measurement of the position effect. A U shape across six models: good at the start (primacy bias), fairly good at the end (recency bias), worst in the middle. The appendix adds GPT-4 and Llama-2.
  3. Three preliminary analyses. Model architecture (decoder-only versus encoder-decoder), where the question is placed (query-aware contextualization), instruction tuning, plus Llama-2 at different sizes. The analyses give clues, not a verdict.
  4. A case study. In open-domain QA, retriever recall keeps rising while the reader model’s score saturates, so the extra documents buy little.
  5. Released code and evaluation data (footnote 1 of the paper).

Experimental design: only move the evidence

Multi-document question answering

Multi-document QA mirrors how RAG is done: give the model a question and several documents, and ask it to answer using only those documents.

ItemSetting
DataThe 2,655 NaturalQuestions-Open questions whose long answer is a paragraph (questions whose long answer is a table or list are dropped); the retrieval corpus is a Wikipedia dump from late 2018
DocumentsWikipedia passages of at most 100 tokens
Input per questionOne document that contains the answer plus k−1 distractor documents that contain no annotated answer, with k = 10, 20, 30
DistractorsRetrieved with Contriever fine-tuned on MS-MARCO: the k−1 passages most relevant to the question that contain no answer, listed in decreasing relevance
Controlling positionReorder the documents to decide where the answer document sits
Controlling lengthAdd or remove distractor documents
MetricAccuracy: the output counts as correct if any annotated answer appears in it; greedy decoding
Prompt”Write a high-quality answer for the given question using only the provided search results (some of which might be irrelevant).” followed by numbered documents and the question

On input length, the paper’s figure titles say about 2K, 4K and 6K tokens, which is only a rough label. The averages in Appendix Table 3 depend on the tokenizer: 1,476, 2,946 and 4,419 tokens with the GPT-3.5-Turbo tokenizer, and 1,750, 3,465 and 5,182 with LongChat-13B’s.

Key-value retrieval

Multi-document QA has natural-language semantics, so a model might get an answer right or wrong because of semantic cues. To isolate the minimal ability of retrieving an exact match from the input, the paper built a synthetic task:

ItemSetting
InputA JSON object with k key-value pairs, where every key and value is a random 128-bit UUID, plus one key to look up
TaskReturn the value for that key: one relevant pair and k−1 distractors
Prompt”Extract the value corresponding to the specified key in the JSON object below.” followed by the JSON and the key
Controlling positionMove the target pair within the JSON
Controlling lengthk = 75, 140, 300, about 4K, 8K and 16K tokens (the averages in Table 4 with the GPT-3.5-Turbo tokenizer are 3,769, 6,993 and 14,929), 500 examples each
MetricThe correct value appears in the output

The models

ModelWindowNotes
MPT-30B-Instruct8,192Pre-trained on 1T tokens with 2,048-token sequences, then 50B tokens with 8,192-token sequences; uses ALiBi for position
LongChat-13B (16K)16,384LLaMA-13B with its window stretched from 2,048 to 16,384 using condensed rotary embeddings (the same family of methods as position interpolation), then fine-tuned on 16,384-token sequences
GPT-3.5-Turbo and GPT-3.5-Turbo (16K)4K, 16KOpenAI API, 0613 versions
Claude-1.3 and Claude-1.3 (100K)8K, 100KAnthropic API
GPT-4 (8K)8KOnly 500 random examples with 20 documents (Appendix D); the paper says evaluating GPT-4 on all experiments would cost upwards of $6,000

Two baselines: closed-book and oracle

To judge whether a score with 20 documents is good or bad you need two reference points (Table 1):

ModelClosed-book (no documents)Oracle (only the document with the answer)
LongChat-13B (16K)35.0%83.4%
MPT-30B-Instruct31.5%81.9%
GPT-3.5-Turbo56.1%88.3%
GPT-3.5-Turbo (16K)56.0%88.6%
Claude-1.348.3%76.1%
Claude-1.3 (100K)48.2%76.4%

Closed-book tests knowledge memorized in the parameters, and oracle approximates an upper bound. Ideally the score with 20 documents lies between the two, as close to the oracle as possible; the position effect makes it swing up and down inside that interval, and sometimes it even falls out of it (see below). The two numbers differ a lot between models, so absolute scores cannot be compared across models directly.

Result 1: the U-shaped curve

The chart below uses the data in Table 6 of the paper’s appendix (20 documents, about 4K tokens):

Position of the answer document and accuracy (20 documents) Line chart: the horizontal axis is the position of the document that contains the answer among 20 documents (1st, 5th, 10th, 15th, 20th) and the vertical axis is multi-document QA accuracy. GPT-3.5-Turbo falls from 75.8% at the 1st position to 53.8% at the 10th and recovers to 63.2% at the 20th, below its closed-book accuracy of 56.1% at the two middle positions; LongChat-13B and MPT-30B-Instruct are U-shaped too, and Claude-1.3 has the flattest curve. Multi-document QA: accuracy depends on where the answer document sits GPT-3.5-Turbo Claude-1.3 LongChat-13B (16K) MPT-30B-Instruct 45 50 55 60 65 70 75 80 Accuracy (%) 1 5 10 15 20 Position of the document that contains the answer (among 20) GPT-3.5-Turboclosed-book 56.1% 75.8 63.2
The chart uses the data in Table 6 of the paper's appendix (20 documents, about 4K tokens); each model has five measured positions (1st, 5th, 10th, 15th, 20th), and the lines between points only suggest the trend. Claude-1.3 (100K) and GPT-3.5-Turbo (16K) differ from Claude-1.3 and GPT-3.5-Turbo by at most 0.3 points and are not drawn again. The dashed line is GPT-3.5-Turbo's closed-book accuracy with no documents at all (Table 1).

The same data as a table, including the longer-window variants, is easier to check:

Model1st5th10th15th20th
Claude-1.359.955.956.857.260.1
Claude-1.3 (100K)59.855.957.057.460.0
GPT-3.5-Turbo75.857.253.855.463.2
GPT-3.5-Turbo (16K)75.757.354.155.463.1
MPT-30B-Instruct53.751.852.252.756.3
LongChat-13B (16K)68.657.455.352.555.0

The numbers are accuracy (%), and the column names give the position of the answer document among the 20. With 10 documents only the 1st, 5th and 10th positions were measured; with 30 documents, seven positions (1st, 5th, 10th, 15th, 20th, 25th, 30th).

Recomputing it

Copy the numbers of Appendix Tables 5 to 7 and of Table 1 into a script, and compute for each setting the best and worst positions, the gap between them, the mean over positions, and the worst position minus the closed-book score. The first part of the script:

# Numbers copied from the paper: Tables 5-7 of Appendix G (accuracy in %
# by the position of the answer document) and Table 1 (closed-book, oracle).
POS = {10: [1, 5, 10], 20: [1, 5, 10, 15, 20],
       30: [1, 5, 10, 15, 20, 25, 30]}
ACC = {
    10: {
        "Claude-1.3": [62.9, 58.3, 59.7],
        "Claude-1.3 (100K)": [63.1, 58.3, 59.7],
        "GPT-3.5-Turbo": [76.8, 61.2, 62.4],
        "GPT-3.5-Turbo (16K)": [76.9, 61.0, 62.5],
        "MPT-30B-Instruct": [60.2, 56.2, 59.7],
        "LongChat-13B (16K)": [72.1, 58.9, 58.5],
    },
    20: {
        "Claude-1.3": [59.9, 55.9, 56.8, 57.2, 60.1],
        "Claude-1.3 (100K)": [59.8, 55.9, 57.0, 57.4, 60.0],
        "GPT-3.5-Turbo": [75.8, 57.2, 53.8, 55.4, 63.2],
        "GPT-3.5-Turbo (16K)": [75.7, 57.3, 54.1, 55.4, 63.1],
        "MPT-30B-Instruct": [53.7, 51.8, 52.2, 52.7, 56.3],
        "LongChat-13B (16K)": [68.6, 57.4, 55.3, 52.5, 55.0],
    },
    30: {  # Table 7 has no 4K-window GPT-3.5-Turbo: 30 documents do not fit
        "Claude-1.3": [59.1, 55.1, 54.8, 55.7, 56.4, 56.2, 59.9],
        "Claude-1.3 (100K)": [59.1, 55.1, 54.9, 55.7, 56.6, 56.1, 60.0],
        "GPT-3.5-Turbo (16K)": [73.4, 55.1, 50.5, 50.9, 51.8, 54.9, 63.7],
        "MPT-30B-Instruct": [51.6, 51.3, 51.2, 49.0, 49.6, 51.3, 54.1],
        "LongChat-13B (16K)": [66.9, 54.8, 52.5, 52.9, 52.2, 51.3, 55.1],
    },
}
CLOSED = {"Claude-1.3": 48.3, "Claude-1.3 (100K)": 48.2,
          "GPT-3.5-Turbo": 56.1, "GPT-3.5-Turbo (16K)": 56.0,
          "MPT-30B-Instruct": 31.5, "LongChat-13B (16K)": 35.0}
ORACLE = {"Claude-1.3": 76.1, "Claude-1.3 (100K)": 76.4,
          "GPT-3.5-Turbo": 88.3, "GPT-3.5-Turbo (16K)": 88.6,
          "MPT-30B-Instruct": 81.9, "LongChat-13B (16K)": 83.4}

# Per setting: best and worst sampled position, their gap, the mean over
# positions, and the worst position minus the closed-book score
for n, rows in ACC.items():
    print(f"== {n} docs ==")
    print(f"{'model':<20}{'best@pos':>11}{'worst@pos':>11}"
          f"{'gap':>6}{'mean':>7}{'w-cb':>7}")
    for model, acc in rows.items():
        hi, lo = max(acc), min(acc)
        print(f"{model:<20}{hi:>6.1f}@{POS[n][acc.index(hi)]:<4}"
              f"{lo:>6.1f}@{POS[n][acc.index(lo)]:<4}"
              f"{hi - lo:>6.1f}{sum(acc) / len(acc):>7.1f}"
              f"{lo - CLOSED[model]:>+7.1f}")

Output:

== 10 docs ==
model                  best@pos  worst@pos   gap   mean   w-cb
Claude-1.3            62.9@1     58.3@5      4.6   60.3  +10.0
Claude-1.3 (100K)     63.1@1     58.3@5      4.8   60.4  +10.1
GPT-3.5-Turbo         76.8@1     61.2@5     15.6   66.8   +5.1
GPT-3.5-Turbo (16K)   76.9@1     61.0@5     15.9   66.8   +5.0
MPT-30B-Instruct      60.2@1     56.2@5      4.0   58.7  +24.7
LongChat-13B (16K)    72.1@1     58.5@10    13.6   63.2  +23.5
== 20 docs ==
model                  best@pos  worst@pos   gap   mean   w-cb
Claude-1.3            60.1@20    55.9@5      4.2   58.0   +7.6
Claude-1.3 (100K)     60.0@20    55.9@5      4.1   58.0   +7.7
GPT-3.5-Turbo         75.8@1     53.8@10    22.0   61.1   -2.3
GPT-3.5-Turbo (16K)   75.7@1     54.1@10    21.6   61.1   -1.9
MPT-30B-Instruct      56.3@20    51.8@5      4.5   53.3  +20.3
LongChat-13B (16K)    68.6@1     52.5@15    16.1   57.8  +17.5
== 30 docs ==
model                  best@pos  worst@pos   gap   mean   w-cb
Claude-1.3            59.9@30    54.8@10     5.1   56.7   +6.5
Claude-1.3 (100K)     60.0@30    54.9@10     5.1   56.8   +6.7
GPT-3.5-Turbo (16K)   73.4@1     50.5@10    22.9   57.2   -5.5
MPT-30B-Instruct      54.1@30    49.0@15     5.1   51.2  +17.5
LongChat-13B (16K)    66.9@1     51.3@25    15.6   55.1  +16.3

The columns: best@pos and worst@pos are the best and worst sampled positions with their accuracy, gap is their difference, mean is the average over the sampled positions, and w-cb is the worst position minus the closed-book score. Some conclusions can be read straight off the output:

  • The gaps are large, and they differ wildly between models. With 20 documents, GPT-3.5-Turbo’s best and worst positions differ by 22.0 points (the paper’s text says “more than 20%”, which matches), LongChat-13B’s by 16.1, and MPT-30B-Instruct’s and Claude-1.3’s by only 4.5 and 4.2. With 10 documents GPT-3.5-Turbo’s gap is 15.6, and with 30 documents (16K variant) 22.9.
  • Only GPT-3.5-Turbo’s worst position falls below closed-book. At the 10th position with 20 documents it scores 53.8% against 56.1% closed-book (the w-cb column shows −2.3); the 16K variant with 30 documents is at −5.5. The other models’ worst positions are still 6.5 to 24.7 points above their own closed-book scores, but their closed-book scores were low to begin with (31.5% to 48.3%).
  • More documents lower the mean, and the loss comes mainly when the answer is in the middle. GPT-3.5-Turbo’s mean over positions falls from 66.8 with 10 documents to 61.1 with 20, while the score at the first position hardly moves (76.8, 75.8, and 73.4 for the 16K variant with 30 documents). The worst position drops from 61.2 to 53.8 to 50.5.
  • The curve does not look the same for every model. With 10 documents there are only three positions, which cannot show a full U. With 20 documents LongChat-13B’s lowest point is the 15th position, and with 30 documents it is the 25th, so the worst position is not always the exact middle, and only a handful of positions were measured.

Next, three more quantities: how asymmetric the two ends are, the position gap as a share of the space between closed-book and oracle, and how much the long-window variants differ from the originals. This is the second part of the script, run right after the first:

print()
# 20 documents: first minus last position; the gap as a share of
# (oracle - closed-book); how far the best position is from the oracle
print("== 20 docs ==")
print(f"{'model':<20}{'first-last':>11}{'gap/room':>10}{'oracle-best':>13}")
for model, acc in ACC[20].items():
    room = ORACLE[model] - CLOSED[model]
    print(f"{model:<20}{acc[0] - acc[-1]:>+11.1f}"
          f"{(max(acc) - min(acc)) / room:>10.0%}"
          f"{ORACLE[model] - max(acc):>13.1f}")

# Largest difference at the same position between a long-window variant
# and the original version
print("== long-window variant vs. short-window version ==")
for a, b in [("Claude-1.3", "Claude-1.3 (100K)"),
             ("GPT-3.5-Turbo", "GPT-3.5-Turbo (16K)")]:
    diff = [abs(x - y) for n in ACC if a in ACC[n] and b in ACC[n]
            for x, y in zip(ACC[n][a], ACC[n][b])]
    print(f"{b:<20} max |diff| = {max(diff):.1f} over {len(diff)} points")

Output:

== 20 docs ==
model                first-last  gap/room  oracle-best
Claude-1.3                 -0.2       15%         16.0
Claude-1.3 (100K)          -0.2       15%         16.4
GPT-3.5-Turbo             +12.6       68%         12.5
GPT-3.5-Turbo (16K)       +12.6       66%         12.9
MPT-30B-Instruct           -2.6        9%         25.6
LongChat-13B (16K)        +13.6       33%         14.8
== long-window variant vs. short-window version ==
Claude-1.3 (100K)    max |diff| = 0.2 over 15 points
GPT-3.5-Turbo (16K)  max |diff| = 0.3 over 8 points
  • Asymmetric ends. first-last is the first position minus the 20th: +12.6 for GPT-3.5-Turbo and +13.6 for LongChat-13B, so the start is clearly better than the end, while Claude-1.3 (−0.2) and MPT-30B-Instruct (−2.6) are nearly symmetric, with MPT leaning slightly toward the end. The U is not symmetric, and the first two are dominated by primacy bias.
  • Normalized, the contrast is sharper. gap/room is the best-to-worst gap divided by oracle minus closed-book: 68% for GPT-3.5-Turbo, 33% for LongChat-13B, 15% for Claude-1.3, 9% for MPT-30B-Instruct. This ratio is this post’s own construction, not a metric from the paper.
  • A longer window does not help. Claude-1.3 (100K) differs from Claude-1.3 by at most 0.2 points across 15 positions, and GPT-3.5-Turbo (16K) from the original by at most 0.3 points across 8. The paper says the extended-context models perform almost identically to the originals, and the appendix numbers bear that out.

Beyond position: the cost of the distractors themselves

The oracle-best column shows something else: even with the answer document at the best position, scores stay far below the oracle that gets only that one document. Splitting the loss relative to the oracle into two parts (20 documents):

ModelOracleBest positionWorst positionDistractor costPosition cost
GPT-3.5-Turbo88.375.853.812.522.0
LongChat-13B (16K)83.468.652.514.816.1
Claude-1.376.160.155.916.04.2
MPT-30B-Instruct81.956.351.825.64.5

The distractor cost is the oracle score minus the best position’s score, and the position cost is the best position’s score minus the worst position’s score, both in points.

The curves of Claude-1.3 and MPT-30B-Instruct are flat, but flat at a much lower level: even at its best position MPT-30B-Instruct is 25.6 points below its own oracle. A flat curve only says a model is insensitive to position; it does not mean it uses a long context robustly. The paper’s criterion is that position should affect the score very little (for instance, a small gap between best-case and worst-case performance). That is a necessary condition, and this post adds one more thing to look at: how far the absolute level is from the oracle.

Result 2: key-value retrieval, where even exact matching fails

Key-value retrieval strips the task down: fetch one random UUID that corresponds to another random UUID, with no semantics to understand. The paper plots accuracy in a figure (Figure 7) and states only a few conclusions in the text, so only those are quoted here:

  • Claude-1.3 and Claude-1.3 (100K) are nearly perfect at every length (75, 140 and 300 pairs).
  • The other models drop clearly at 140 and 300 pairs, even though the task only requires an exact match.
  • GPT-3.5-Turbo, GPT-3.5-Turbo (16K) and MPT-30B-Instruct score lowest when the target pair is in the middle of the input, consistent with the trend in multi-document QA.
  • LongChat-13B (16K) behaves differently at 140 pairs: the authors observe qualitatively that when the target pair is at the start, it tends to write code that would look up the key instead of outputting the value.

The significance is that the position effect in multi-document QA cannot be blamed entirely on “semantically similar documents distracting the model”. The pairs are random UUIDs with no semantics at all, and some models still fail in the middle.

Why it happens: three preliminary analyses

Section 4 of the paper calls itself a “preliminary investigation”. The three analyses and what they found:

QuestionMethodFinding
Is it the architecture?Compare decoder-only models with encoder-decoder models (Flan-T5-XXL, Flan-UL2)Within its 2,048-token training window Flan-UL2 is insensitive to position (best and worst differ by only 1.9 points); beyond the training length a U shape appears. Flan-T5-XXL (trained at 512 tokens) behaves similarly: the longer the input, the more it loses when the information is in the middle. The authors guess that a bidirectional encoder can process each document in the context of the later ones, which may help it estimate their relative importance
Does the question’s position matter?Put the question both before and after the documents (query-aware contextualization)Key-value retrieval: every model is nearly perfect, and GPT-3.5-Turbo (16K) reaches 100% at 300 pairs, against a worst case of 45.6% without it. Multi-document QA: the trend hardly changes, slightly better at the first position and slightly worse elsewhere
Is it instruction tuning?Compare MPT-30B with MPT-30B-InstructBoth are U-shaped, and Instruct scores higher overall. The paper concludes that instruction tuning itself is not necessarily responsible. It guesses that base models also learned to use long contexts from question-and-answer-style text in the pre-training corpus
Does scale matter?Llama-2 at 7B, 13B and 70B, each as a base model and as a chat model (SFT plus RLHF) (Appendix E, 20 documents)13B and 70B are U-shaped, while 7B leans only toward the end (recency bias). The 13B base model has a best-to-worst gap of about 20 points, reduced to about 10 after fine-tuning; for 70B, fine-tuning changes little

The paper adds a conjecture about earlier work: previous studies, which looked at models with fewer than 1B parameters, did not observe primacy bias, perhaps because those models were too small. That is a hypothesis; the paper does not test it.

Two things to keep in mind when reading. First, the paper has no dedicated comparison of positional encodings. Among the tested models, MPT uses ALiBi and LongChat uses condensed RoPE, and both show the U shape, while the paper does not disclose the positional encoding of GPT-3.5 or Claude, so you cannot conclude that a particular positional encoding causes the U shape; for the details see positional encoding. Second, query-aware contextualization only repairs key-value retrieval: when the task is to retrieve, letting the documents see the question while they are encoded is enough; when the task is to understand and answer, it is not.

Case study: is it worth stuffing in more documents

In the controlled experiments the input has exactly one document with the answer. In real open-domain QA, the retrieved documents may contain none, or several. The paper retrieved from Wikipedia with Contriever for the part of NaturalQuestions-Open whose long answer is a paragraph, put the top k retrieved documents straight into the prompt, varied k from 5 to 50, and measured both the retriever’s recall and the reader model’s accuracy.

The result (Figure 11): the retriever’s recall keeps rising with k, while the reader’s score saturates early. Beyond k = 20 the score improves only slightly, by about 1.5 points for GPT-3.5-Turbo and about 1 point for Claude-1.3, while the input is 2.5 times longer, with the latency and cost that go with it. The authors suggest two directions: reranking the retrieved documents so that the relevant ones move toward the start of the input, or truncating the ranked list so that fewer documents are retrieved when appropriate (ranked list truncation). They are presented as directions worth exploring; the paper does not compare QA scores before and after reranking.

Robustness checks: is the finding an artifact of the setup

The appendix runs several checks:

CheckMethodConclusion
Question ambiguitySome NaturalQuestions-Open questions have several reasonable answers, and the retrieval corpus (Wikipedia of late 2018) is out of step in time with the annotations; take the unambiguous subset using the annotations of Min et al. (2020)Similar conclusions
Random distractorsReplace the retrieved hard distractors with randomly drawn Wikipedia passagesAbsolute scores are higher for every model, but they still struggle to use the whole input, so the degradation is not only a failure to recognize the relevant document
Order of distractorsRetrieved distractors are listed by decreasing relevance, and models may have learned a prior that earlier search results are more useful; shuffle the distractors and say in the prompt that the order is randomStill U-shaped; the score drops slightly when the answer is at the very start and rises slightly in the middle and at the end
A stronger modelGPT-4 (8K), 500 random examples, 20 documents (Appendix D)Higher absolute scores than every other model, still U-shaped

These checks do not rule out every explanation, but they show that the U shape is not produced by Contriever’s hard distractors, by question ambiguity, or by an ordering hint in the prompt.

What it means for RAG and prompt design

The paper itself proposes only two remedies, reranking and truncation; the rest are inferences from its findings. The table marks how strong the evidence for each is:

PracticeEvidenceStrength of evidence
Retrieve less: cut top-k where the gain saturatesGoing from 20 to 50 documents adds only about 1 to 1.5 points while the input grows 2.5 timesDirect experiment in the paper
Rerank: put the most relevant documents firstGPT-3.5-Turbo and LongChat-13B score 15 to 22 points higher at the first position than in the middle; the paper suggests this directionProposed by the paper, but post-reranking scores were not measured
Repeat the question after the documentsKey-value retrieval goes from a 45.6% worst case to 100%; multi-document QA barely changesEvidence only for exact-retrieval tasks
Do not use window length as a substitute for measurementLong-window variants differ from the originals by at most 0.3 points at the same positionDirect experiment in the paper
Measure position in your own systemThe paper’s protocol: fix the task and the content, move only the evidence, and plot the score against positionA method that works for any model

Other common practices, such as compressing the background material in the middle, splitting a long task into steps, and adding numbers and headings to evidence, were not tested in the paper. They are worth trying, but the same “move only the position” protocol is the way to check whether they help. Reproducing the protocol in your own system takes a few steps:

  1. Take a batch of questions with reference answers, and for each find the document that contains the answer plus several distractors.
  2. For each question, put the answer document first, at several middle positions, and last, leaving the content and order of the other documents unchanged.
  3. Compute the accuracy at each position and plot it as a curve. Measure the closed-book and oracle baselines too, to confirm the scores with documents lie between them.
  4. Only when the gap between the best and worst positions is small can you say the model is robust to position on this task.

For more on assembling context in RAG, see the context assembly section of RAG.

Limitations and cautions when reading

These numbers belong to 2023 models

The models tested were GPT-3.5-Turbo-0613, Claude-1.3, MPT-30B-Instruct and LongChat-13B (16K) from 2023. The closed APIs have been updated since, so these numbers should not be read as the scores of current models; the paper itself saw a different shape in Llama-2.

  • Task setup. Multi-document QA has exactly one relevant document, and the distractors are hard negatives retrieved for the same question; in real RAG, the relevant evidence is often spread over several complementary documents. Key-value retrieval is synthetic and far from real usage.
  • Metric. “Any annotated answer appears in the output” is lenient for rambling answers and strict for correct answers worded differently. The oracle differs by model (76.1% for Claude-1.3, 88.3% for GPT-3.5-Turbo), so absolute scores cannot be compared across models directly.
  • Only a few positions were measured. Three positions for 10 documents, five for 20, seven for 30; where the bottom of the curve lies is only an estimate, and the line chart drawn here is only an illustration.
  • No answer on the mechanism. The three analyses are preliminary. The paper does not explain how the U shape arises, and it does not test guesses such as that the task description usually sits at the beginning of training data.
  • Conclusions given only as figures. Many conclusions in the paper’s text are shown only in figures (Figures 5, 7, 8 and so on); this post uses Appendix Tables 5 to 7 and the numbers the text states explicitly.
  • Read it next to later evaluations. Beyond position, the effective length of a window is also shorter than the advertised one; see the discussion of RULER in long context.

What to take away from this paper

  1. Window length is not capability. Fitting in is not the same as being used; only an experiment that moves the evidence around can tell.
  2. Look at the curve, and at the level. The paper’s criterion is a small gap between positions; check the absolute level against the oracle too, because a curve that is flat but low is not robust.
  3. The closed-book and oracle baselines are indispensable. Without them a score of 55% is neither good nor bad.
  4. Do not expect a longer window to fix it. The same model with a window of 16K instead of 4K, or 100K instead of 8K, scores almost the same at the same position.
  5. In RAG, recall is followed by “is it used”. The gain from more documents saturates quickly while the cost grows linearly; ranking and truncation are worth doing before simply raising k.

Further reading

FAQ

What did Lost in the Middle find?
When the position of the relevant information in a long input changes, accuracy follows a U shape: it is highest when the information is at the beginning or end and lowest when it is in the middle. In multi-document QA with 20 documents, GPT-3.5-Turbo scores 75.8% when the answer document is first, 53.8% when it is tenth, which is below its 56.1% closed-book score with no documents at all. The authors conclude that models do not robustly use their whole long context.
How were the experiments run?
Two tasks, changing only where the relevant information sits or how long the input is. Multi-document QA uses 2,655 NaturalQuestions-Open questions, each with 10, 20 or 30 Wikipedia passages, exactly one of which contains the answer while the rest are retrieved distractors. Key-value retrieval asks the model to return the value of a given key from 75, 140 or 300 random UUID pairs. The models were MPT-30B-Instruct, LongChat-13B (16K), and GPT-3.5-Turbo and Claude-1.3 in two window sizes each, with GPT-4 and Llama-2 tested on subsets.
Does a longer context window make the problem go away?
Not in this paper. GPT-3.5-Turbo (4K) and GPT-3.5-Turbo (16K), and Claude-1.3 (8K) and Claude-1.3 (100K), differ by at most 0.3 points at the same position, so their curves nearly coincide; GPT-4 (8K) scores higher but is still U-shaped. The models are from 2023, though, and the strength of the effect varies with the model and its training (Llama-2 7B, for example, shows only a recency bias), so measure it on your own model and task.
What does this mean for RAG systems?
Two points have direct evidence in the paper. Going from 20 to 50 retrieved documents raised GPT-3.5-Turbo's accuracy by only about 1.5 points and Claude-1.3's by about 1 point, while the input grew 2.5 times, so truncate the retrieved list. Position matters a lot, and the authors suggest reranking so that the most relevant documents move toward the start of the input. Putting the question both before and after the documents makes key-value retrieval nearly perfect but barely helps multi-document QA.
Why does the U-shaped curve appear?
The paper does not settle it. It ran three preliminary analyses: an encoder-decoder model (Flan-UL2) is insensitive to position within its training length and shows the U shape only beyond it; instruction tuning is not necessarily the cause, because the base model MPT-30B is U-shaped too; and scale matters, since Llama-2 13B and 70B show the U shape while 7B leans only toward the end. It characterizes the phenomenon rather than explaining the mechanism.