NoLiMa: Long-Context Evaluation Beyond Literal Matching
- Publication
- ICML 2025Conference
- First submitted to arXiv
- arXiv:2502.05167
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{modelevaluationnolima2025,
title = {{NoLiMa: Long-Context Evaluation Beyond Literal Matching}},
author = {Ali Modarressi and Hanieh Deilamsalehy and Franck Dernoncourt and Trung Bui and Ryan Rossi and Seunghyun Yoon and Hinrich Schütze},
year = {2025},
eprint = {2502.05167},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2502.05167}
}
From 2024 onward, model launches advertised ever larger context windows of 128K, 1M, and even 2M tokens.
The most common way to demonstrate that a model can read that much is the needle-in-a-haystack test (NIAH), which hides a sentence inside a large amount of irrelevant text and then asks the model what it says.
The popular version Greg Kamradt introduced in 2023 hid this sentence:
The best thing to do in San Francisco is eat a sandwich and sit in Dolores Park on a sunny day.
The question was:
What is the most fun thing to do in San Francisco?
See the problem?
“San Francisco” appears unchanged in both the question and the needle. The model can find the same words in the context, with the answer right beside them, without understanding anything.
This paper comes from LMU Munich and Adobe Research. The authors want to know whether the model can still find the needle once those literal clues are removed.
Defining the Problem
The authors first measure, for existing long-context benchmarks, how similar the words in the question are to those in the passage containing the answer.
They use ROUGE precision to measure how many words from the question appear in the relevant passage. Higher values mean more shared words:
| Benchmark | ROUGE-1 | ROUGE-2 | ROUGE-L |
|---|---|---|---|
| Vanilla NIAH | 0.905 | 0.789 | 0.855 |
| RULER S-NIAH | 0.571 | 0.461 | 0.500 |
| RULER QA | 0.809 | 0.437 | 0.693 |
| ∞Bench QA | 0.966 | 0.545 | 0.960 |
| NoLiMa | 0.069 | 0.002 | 0.067 |
Compiled from Table 1 of the paper.
Vanilla NIAH reaches a ROUGE-1 of 0.905: about 90% of the question's words can be found in the needle. Multi-document and long-document QA benchmarks also have substantial overlap.
The authors argue that attention is good at recalling repeated patterns. This overlap may make finding information in a long context much easier. How much of the advertised length is supported by simple word matching?
The authors therefore set out to build a benchmark where the task itself is simple, but literal matching provides no help.
Solving the Problem
A Needle That Cannot Be Found by Matching Words
NoLiMa has the same skeleton as NIAH, with one needle in a pile of hay. The difference is how the needle and question are written.
Here is a needle:
Actually, Yuki lives next to the Semper Opera House.
Its question is:
Which character has been to Dresden?
The question contains neither Yuki nor Semper Opera House; the needle contains no Dresden. The only connection between them is the world knowledge that the Semper Opera House is in Dresden.
The model must make that association to connect the question with the needle and answer “Yuki.”
The authors distinguish two keywords, in the question (here Dresden) and in the needle (here Semper Opera House).
Add another layer and it becomes two-hop:
Which character has been to the state of Saxony?
Now the model must reason through two connections: the opera house is in Dresden, and Dresden is in Saxony.
Some needles use commonsense rather than world knowledge. For example, the needle says, “Then Yuki mentioned that he has been vegan for years,” and the question asks which character cannot eat fish dishes.
Cleaning the Hay
The hay comes from ten openly licensed books. To reduce the possibility of memorization, the authors do not use whole books directly. They concatenate randomly selected passages of fewer than 250 tokens from randomly selected books.
Then comes an important cleanup. Two kinds of content must be removed:
- Words too similar to question keywords. Use Contriever to embed each word in the hay, find the 20 most similar words for each , inspect them manually, and remove sentences containing those words.
- Content that could serve as an answer. Split the hay into passages of about 250 tokens and give each passage and question to Llama 3.3 70B to check for answers. The authors manually review flagged passages for removal, repeating until no further removals are needed.
Otherwise, a character in the hay might happen to have visited Dresden, making scoring ambiguous.
How Is It Scored?
Each needle is placed at 26 evenly spaced positions within the tested length. With five random haystacks and 58 question–needle pairs, that gives 7,540 tests per length. Lengths range from 250, 500, and 1K up to 32K tokens.
Every question asks for a character's name, so an answer is correct if it contains the right name.
Two metrics need clarification.
Base score uses the three shortest lengths: 250, 500, and 1K. For each question–needle pair, average over the five haystacks, take the highest of the three length scores, then average across questions. It describes how well the model can answer with almost no hay interference.
Effective length is the largest tested length at which performance remains at least 85% of the base score.
Let's calculate this for GPT-4o. Its base score is 99.3, giving a threshold of:
Its scores by length are:
| Length | 1K | 2K | 4K | 8K | 16K | 32K |
|---|---|---|---|---|---|---|
| GPT-4o | 98.1 | 98.0 | 95.7 | 89.2 | 81.6 | 69.7 |
Excerpted from Table 3 of the paper.
At 8K, 89.2 is still above 84.4. At 16K, 81.6 is below it. GPT-4o's effective length is therefore 8K, against an advertised 128K.
Using each model's own base score separates intrinsic task difficulty from degradation caused by length. A model that struggles even in short contexts starts with a lower base score and a lower threshold.
Discussion
Main Results
The authors test 13 models advertised to support at least 128K tokens:
| Model | Advertised length | Effective length | Base score | 32K |
|---|---|---|---|---|
| GPT-4o | 128K | 8K | 99.3 | 69.7 |
| Llama 3.3 70B | 128K | 2K | 97.3 | 42.7 |
| Llama 3.1 405B | 128K | 2K | 94.7 | 38.0 |
| Llama 3.1 70B | 128K | 2K | 94.5 | 43.2 |
| Gemini 1.5 Pro | 2M | 2K | 92.6 | 48.2 |
| Jamba 1.5 Mini | 256K | <1K | 92.4 | 43.6 |
| Command R+ | 128K | <1K | 90.9 | 7.4 |
| Gemini 2.0 Flash | 1M | 4K | 89.4 | 41.0 |
| Mistral Large 2 | 128K | 2K | 87.9 | 18.8 |
| Claude 3.5 Sonnet | 200K | 4K | 87.5 | 29.8 |
| Gemini 1.5 Flash | 1M | <1K | 84.7 | 28.6 |
| GPT-4o mini | 128K | <1K | 84.8 | 13.7 |
| Llama 3.1 8B | 128K | 1K | 76.7 | 14.2 |
Compiled from Table 3 of the paper. The complete table also gives scores at lengths from 1K through 16K.
In the base-score column, most models score in the 80s or 90s in short contexts, showing that the needles themselves are not difficult.
In the effective-length column, apart from GPT-4o at 8K, all models are at 4K or below, many at 2K or even below 1K.
Plotting advertised and effective lengths on the same logarithmic axis makes the gap clearer:

Finally, at 32K, eleven of the 13 models score below half their own base score. Only GPT-4o and Gemini 1.5 Pro retain at least half.
The authors also compare the same model across benchmarks. Llama 3.1 70B has an effective length of 16K on BABILong and 32K on RULER. On NoLiMa, it falls to 2K.
The ranking by base score also differs from the ranking by effective length. Claude 3.5 Sonnet and Gemini 2.0 Flash have lower base scores than Llama 3.3 70B, yet effective lengths of 4K rather than 2K. At 4K, their raw scores also exceed those of some models with higher base scores.
Two Hops Are Harder Than One; Inverted Order Is Harder Than Default
The authors examine two factors using GPT-4o and Llama 3.3 70B.
Hop count: At the same length, two-hop questions are harder, and the gap widens as context grows. Within 4K, GPT-4o still handles both reasonably well.
Word order: The inverted “Next to the Semper Opera House lives Yuki” is harder than the default “Yuki lives next to the Semper Opera House.”
The authors link this to causal attention in the decoder. With default order, the name appears first, so the representation at “Semper Opera House” already carries information about Yuki. Dresden in the question can connect to the opera house and then to Yuki. With inverted order, Yuki has not appeared when the opera house is read; connecting there yields no name, leaving a weaker signal on the name's side. The authors also state that a deeper mechanistic analysis is beyond the paper's scope.
Is the Problem Position or Length?
Readers of Lost in the Middle may wonder whether scores decline because the needle happens to fall in the middle.
The authors perform two position sweeps with Llama 3.3 70B.
The first is a full-range sweep, placing the needle from 0% to 100% of the context. One-hop questions do show the familiar lost-in-the-middle pattern, getting worse toward the middle. Two-hop questions behave differently, with the whole curve sinking as context grows, beginning and end included.
The second, cleverer design, called align within the last 2K, places the needle at fixed positions within the final 2K tokens, whether the total context is 4K or 32K.
The needle-to-question distance is then identical across total lengths. Llama 3.x uses RoPE, a relative positional encoding based on distances between tokens. If positional encoding were the cause, the same distances should produce similar scores.
Instead, the two-hop curves are fairly flat within the last 2K, with little position effect, but the entire curve falls as total context length grows.
With distance held fixed, the authors attribute the main limitation to length itself. With more tokens to attend to and no literal clues, attention has a harder time finding the relevant fact.
Does Thinking Help?
If association is required, what about asking the model to write its reasoning first—Chain-of-Thought, or CoT?
The authors compare direct answers with answers preceded by at most three reasoning sentences using Llama 3.3 70B:
| Length | 4K | 8K | 16K | 32K |
|---|---|---|---|---|
| One-hop, direct | 90.3 | 84.1 | 73.2 | 56.2 |
| One-hop, CoT | 95.6 | 91.1 | 82.6 | 60.6 |
| Two-hop, direct | 70.7 | 57.4 | 42.7 | 25.9 |
| Two-hop, CoT | 82.4 | 70.1 | 56.7 | 34.3 |
Compiled from Table 4 of the paper.
CoT helps, especially on two-hop questions. But two-hop CoT only roughly catches up with one-hop direct answering, and performance remains poor at 16K and above.
The authors explain that these questions contain only one clue and cannot be decomposed into easier steps. The hard part is associating Dresden with the Semper Opera House, and that step is precisely what becomes difficult in a long context.
They also select the ten hardest question–needle pairs as NoLiMa-Hard to test reasoning models. GPT-o1, GPT-o3 Mini, and DeepSeek R1-Distill-Llama-70B all have near-perfect base scores, but all fall below 50% at 32K, with 31.1 for GPT-o1, 18.9 for o3 Mini, and 20.7 for distilled R1.
Put the Literal Clues Back
The final ablations test the central hypothesis by adding literal clues back and seeing how scores change.
The authors create two comparisons:
- Direct: The question explicitly mentions the needle's keyword, as in vanilla NIAH.
- Multiple Choice: Keep the question, but add four name options, one from the needle and three from the hay. This adds the name as a literal link between question and needle.
| Setting | 8K | 16K | 32K |
|---|---|---|---|
| Direct | 98.3 | 98.5 | 98.5 |
| One-hop | 84.1 | 73.2 | 56.2 |
| One-hop + choices | 98.7 | 97.4 | 93.1 |
| Two-hop | 57.4 | 42.7 | 25.9 |
| Two-hop + choices | 96.3 | 94.6 | 87.2 |
Compiled from Table 6 of the paper, using Llama 3.3 70B.
The result is clear. Direct questions still score 98.5 at 32K. Adding answer choices raises two-hop performance at 32K from 25.9 to 87.2.
Literal clues can also mislead. The authors insert a sentence containing , such as Dresden, but unrelated to the needle and question. Its wording makes it look more like an answer than the real needle. With this distractor, GPT-4o's effective length shrinks from 8K to 1K; Llama 3.3 70B fares even worse.
What About Newer Models?
The v3 appendix tests newer models and extends some evaluations to 64K and 128K. To control API costs, it reduces placement positions from 26 to 11 per length.
GPT-4.1 advertises 1M, has an effective length of 16K, and still scores 64.7 at 128K. GPT-4o scores 56.0 at 128K; Gemini 2.0 Flash falls to 16.4. Llama 4 Scout advertises 10M but has an effective length of only 1K.
A first-page footnote states that newer models have improved at long contexts, but the central finding still holds, with scores beginning to fall sharply far below advertised lengths.
Conclusion
NoLiMa removes an easily overlooked shortcut in needle-in-a-haystack tests, so that the question and needle share no words and are linked only by a simple association.
Under this setup:
- Advertised and effective lengths differ greatly. Of 13 models, only GPT-4o reaches an effective length of 8K. At 32K, 11 fall below half their own base scores.
- The difficulty combines association with length. Two-hop curves sink across all positions, including the beginning and end. Distance-aligned experiments point to context length as a cause beyond position alone.
- CoT and reasoning models help, but leave a large gap. All three reasoning models score below 50% at 32K on NoLiMa-Hard.
- Literal clues have a large effect. Adding choices raises two-hop performance at 32K from 25.9 to 87.2. Adding misleading matching words instead shrinks GPT-4o's effective length to 1K.
In their conclusion, the authors also extend this finding to search and RAG, where the document containing the answer may use entirely different words from the question, while a document with similar wording but no answer may pull the model off course.
Many models can fit 128K. Far fewer can still find the answer when the question is phrased differently.