TL;DR
Language models now advertise context windows of 128K tokens or more, meaning they accept that much text in one prompt. The usual test for them, needle in a haystack, asks a model to find one planted fact in a long document, and most models ace it. RULER is a benchmark of 13 tasks in four families that go past plain lookup: several needles, tracing a variable through a chain of assignments, counting words across a long text, and question answering over many documents. Across 17 long-context models, almost all of them drop sharply as the input grows, and the effective length is often far below the claimed one.
Builds on: In-Context Learning, since several RULER tasks put worked examples in the prompt, and the idea of a model reading a prompt as one sequence · Leads to: later long-context evaluations; for a related failure mode, see the lost-in-the-middle study
Why it mattered
Many models released in 2023 and 2024 advertised long context windows. RULER gave the field a way to check the advertised number. Its authors ran the test on 17 long-context models, 15 open and 2 closed, including Gemini-1.5-Pro and GPT-4. Every model in the study claims a context of 32K tokens or more, and the paper shows that the usable length is often shorter.
The benchmark is also a template. Its generator takes a target length and a difficulty setting and writes a fresh test case, so a lab can measure the same model at 4K, 32K or 128K and see the curve, not one point. Synthetic, controllable tasks like these can be scaled to any length.
The problem
Before RULER, the standard long-context check was the needle-in-a-haystack test, or NIAH. A short fact, the needle, is hidden at some point in a long filler text, the haystack, and the model is asked to retrieve it. The test is simple and it is useful, but it measures one thing: retrieval of a single item by an exact match on a key. A model can pass it by locating the matching string and copying what follows it.
The paper's question is what the test misses. Long-context use involves keeping track of several items at once, ignoring distractors that look like the target, following references through a chain, combining evidence from across the text, and answering questions where the key is only loosely matched. None of these are tested by one lookup. The authors also note that prior evaluations used the test inconsistently, so numbers were hard to compare across papers.
The prerequisite In-Context Learning matters here. Several RULER tasks include a worked example at the start of the prompt, and the model is expected to pick up the pattern and apply it to the long input that follows. A model that copies the example instead of solving the task fails in a way the simple test cannot show.
How it works
The pipeline runs in the order below. Each test case is generated, sent to a model, and scored, and the scores are then combined into one number per model and length.
flowchart LR A["Choose task and length, 4K to 128K"] --> B["Generate example: haystack plus needles or chains"] B --> C["Append answer prefix, apply chat template"] C --> D["Model decodes greedily"] D --> E["Recall-based accuracy: is the target in the output"] E --> F["Average over 13 tasks at each length"] F --> G["Compare with threshold: effective length"]
- Pick a task and a length. For each task, the authors generate 500 examples at each length from 4K, 8K, 16K, 32K, 64K and 128K tokens. Length controls the size of the haystack or the number of distractor words, so the same task can be made longer without changing its logic.
- Build the example. For the simplest case, single needle retrieval (S-NIAH), the generator writes a sentence such as "One of the special magic numbers for long-context is: 12345." and hides it in a haystack of essays. It then adds a question at the end. The target answer is the number.
- Add a challenge where needed. Other tasks add difficulty by changing the structure. Multi-keys adds distractor needles with other keys. Multi-values asks for all values that share one key. Variable tracking builds a chain of assignments such as X2 = X1 and X3 = X2, and asks for every name that holds the same value.
- Append the answer prefix. The input ends with a prefix that starts the answer, so the model is less likely to refuse or to explain itself. The chat template for each model is applied first.
- Decode and score. The model runs with greedy decoding, which means it always picks the most likely next token. The output is scored by recall-based accuracy: the fraction of the target strings that appear somewhere in the output. Extra words do not hurt, but a missing item does, so an answer with only part of the required set scores as partial.
- Average the tasks. At each length, the score is the mean over the 13 tasks. This gives one number per model per length, which is the number in Table 3.
- Find the effective length. The authors take a threshold from a reference model, Llama2-7B at 4K, which scores 85.6. The effective length is the longest tested length at which the model still scores above that threshold.
Step 7 is the key idea of the paper. A model's claimed length tells you the input it accepts. The effective length tells you how far it stays useful, measured against a baseline that everyone knows.
The math
Step 5 in symbols: recall-based accuracy
For one example with target set and model output , a simple form of recall accuracy is
where is 1 when the statement is true and 0 otherwise. The paper uses this recall-based check, so a model that returns two of three required values gets partial credit. Here is the number of values the task asks for, and means that the value appears somewhere in the output.
Step 6 in symbols: the average over tasks
If is the score of task at length , and there are tasks, the model's score at length is
This is the "Avg." column in Table 3 for each length.
Step 7 in symbols: effective length
Let , the score of Llama2-7B at 4K. The effective length of a model is
Read this as: the largest tested length whose average score is above the threshold. The definition needs to be read at the tested lengths only, so the paper's effective length is a grid value, not a continuous quantity. In Table 3, a model whose effective length is listed as below 4K fails the threshold even at the shortest length.
A weighted summary
Single lengths can be misleading, so the paper also summarises each model with a weighted average over lengths. If are weights over the tested lengths, the summary is
Two weightings are used. In one, rises linearly with length, which favours long inputs. In the other, it falls, which favours short ones. Which summary to read depends on how long the inputs in the target application are.
Results
The headline numbers come from Table 3 of the paper. Scores are averages over the 13 tasks, in percent.
- Vanilla retrieval is not the problem. The paper reports that most models achieve nearly perfect accuracy on passkey retrieval and on vanilla NIAH. The failure appears only when the other tasks are added.
- Claimed and effective lengths differ widely. Gemini-1.5-Pro's effective length is greater than 128K, the longest tested. GPT-4 claims 128K and has an effective length of 64K. Llama3.1 (70B) claims 128K and also has an effective length of 64K. Yi (34B) claims 200K and has an effective length of 32K. Mistral-v0.2 (7B) claims 32K and has an effective length of 16K. LWM (7B) claims 1M and has an effective length below 4K.
- Degradation is steep for many models. GPT-4 scores 96.6 at 4K and 81.2 at 128K. Yi (34B) scores 93.3 at 4K and 77.3 at 128K. Mixtral-8x22B scores 95.6 at 4K and 31.7 at 128K.
- Bigger context claims do not guarantee better results. The paper notes that the top open models include both brute-force scaling, such as Llama3.1 trained on 128K, and inference-time extrapolation, such as Qwen2 trained on 32K. It also notes that some models trained on 1M-token contexts rank low.
- Short-context performance can trade off against long. LWM ranks higher than Mistral-v0.2 under the increasing-weight summary, but it scores below Llama2-7B even at 4K. The paper flags this as a trade-off in how to read the table.
The paper's own summary of its findings is that all models claim context sizes of 32K tokens or greater, while only about half of them keep satisfactory performance at 32K. The table is more detailed. Ten of the 17 models have an effective length of 32K or more, and the rest fall below that. Read the result as a comparison of how far each model's useful range falls short of its claim, not as a pass or fail.
Limits. The paper says that RULER is a synthetic benchmark, so its tasks are proxies for real long-context use. Variable tracking and frequent-word extraction stand in for harder natural tasks, and the authors have not checked that they predict those tasks well. The benchmark also reports one number per length, which hides where in the input the errors occur. A model that fails only when the key sits in the middle of the text would look the same as one that fails everywhere at that length. The authors also did not test prompt robustness beyond a preliminary check.
Error analysis of one model. The authors examined Yi (34B) in more detail, up to 256K tokens. Three findings stand out:
- Performance drops by about 40 points at 256K when the haystack is full of distractor needles.
- Increasing the number of queries from 1 to 8 drops performance by about 15 points.
- At 128K, over 80 percent of the output for the common-words task is a string copied from the one-shot example in the prompt, rather than a count of words in the context.
These point to failure modes that a single lookup test does not reveal: ignoring distractors, returning complete sets, and copying instead of reasoning over the input.
Reading guide
Read the paper in this order. Each section uses the lessons listed beside it.
- Section 1, Introduction. Motivation and the four task categories. Needs In-Context Learning and an idea of what a prompt is.
- Section 2, Related Work. The long-context methods, such as positional encodings and retrieval. For the ideas behind the encodings, read Rotary Position Embedding and Extending Context Window of Large Language Models via Positional Interpolation. For retrieval, read Retrieval-Augmented Generation.
- Section 3, The RULER Benchmark. The task designs and Table 2. Needs Attention Mechanism to see why a long context is hard to attend over, and Open-Domain Question Answering for the QA task family.
- Section 4, Experiments and Results. The effective-length method and Table 3. Needs the average and threshold ideas above.
- Section 5, Task Error Analysis. The failure modes in Yi-34B. For the related finding that models use information near the ends of a long input more than the middle, read Lost in the Middle: How Language Models Use Long Contexts.
- Section 6, Model Analysis. The effect of training length, model size and architecture. Needs Transformer and Language Model to see why the non-Transformer comparisons matter.
- Sections 7 and 8. Conclusion and limitations. Read the limitations before quoting any single score.
Check yourself
QuestionRULER uses a threshold of 85.6 to define effective length. Where does that number come from, and what does a model with an effective length of 32K mean?Show answer
85.6 is the average score of Llama2-7B at the 4K length, taken as the reference. A model with an effective length of 32K has an average score above 85.6 at 32K and does not stay above it at 64K. Its claimed length can be larger, but the paper treats 32K as the length it can use satisfactorily.
QuestionA model answers 2 of the 3 required values in a multi-values test. Under the recall-based form , what is its score for that example?Show answer
With and two values found, , or about 66.7 percent. The score is partial credit, not zero, but the missing value counts against the model.
QuestionWhy does RULER include tasks such as variable tracking and common-words extraction, when the needle-in-a-haystack test already exists?Show answer
The needle test checks one lookup, which a model can pass by matching a key and copying the following text. Variable tracking requires following a chain of references, and common-words extraction requires counting over a long input. These tasks test whether the model uses the long input in ways the lookup test does not, so they reveal failures that the lookup test hides.
QuestionSuppose a model scores 92 at 4K, 90 at 32K and 84 at 64K, against the threshold of 85.6. What is its effective length under the paper's definition?Show answer
The longest tested length with a score above 85.6 is 32K, since 90 is above the threshold and 84 is below it. The effective length is 32K.
QuestionGive one reason the paper's authors caution against using RULER alone to choose a model for a real application.Show answer
RULER is synthetic, and its tasks are proxies for real long-context use that the authors could not check against realistic tasks. It also reports a single score per length, which hides where in the input the errors occur, so a model could look equal while failing differently. The authors say RULER should not be preferred over more realistic settings, such as the NoCHA benchmark.