Skip to content

RULER: What's the Real Context Size of Your Long-Context Language Models?

Skip →Context Rot
LLM stage 2 #3corefrontierpaperrubric 11/122024 · COLM 2024 · ~40 min

Cheng-Ping Hsieh, Simeng Sun, Samuel Kriman, …, Boris Ginsburg

Status

TL;DR. Needle-in-a-haystack is too easy: almost every long-context model passes it. RULER generates 13 tasks in four families (retrieval, multi-hop tracing, aggregation and QA) at any length and difficulty. Of 17 models evaluated, only Gemini-1.5-Pro stays above the quality bar at 128K, and most hold up for half their claimed window or less.

Why it matters now. RAG readers, listwise rerankers and deep-research agents are given longer and longer prompts on the assumption that the advertised window is usable. RULER puts a number on how much of it is. It is also a template for building synthetic, controllable evaluations, a skill directly useful for IR benchmarks.

Generate each task from a configuration that sets length LL and difficulty, run each model on 500 examples per length L∈{4K,…,128K}L \in \{4\text{K}, \dots, 128\text{K}\}, and average the 13 task accuracies into S(L)S(L). Two summaries follow:

Leff=max⁡{L:S(L)>85.6},wAvg=∑jwj S(Lj)∑jwj,    wj=j (inc) or 7−j (dec).L_{\text{eff}} = \max\{L : S(L) > 85.6\}, \qquad \text{wAvg} = \frac{\sum_{j} w_j\, S(L_j)}{\sum_j w_j},\;\; w_j = j \text{ (inc) or } 7 - j \text{ (dec)}.

The threshold 85.6 is Llama2-7B’s score at 4K. The weights simulate usage dominated by long (inc) or short (dec) inputs.

RULER: thirteen synthetic tasks in four families, and claimed versus effective context length Left: the four RULER task families. Retrieval extends needle-in-a-haystack with multiple keys, multiple values, multiple queries and distractor needles. Multi-hop tracing asks the model to follow chains of variable assignments. Aggregation asks for the most common or most frequent words across the whole input. Question answering hides the gold paragraph among distractor paragraphs. Right: for eight models, a dashed outline shows the claimed context length and a filled bar shows the effective length, the longest length at which the model still beats Llama-2-7B at 4K (85.6). The axis is logarithmic from 4K to 1M. Only Gemini-1.5-Pro keeps above the threshold at 128K; GPT-4 and Llama3.1-70B hold to 64K of a claimed 128K; LWM claims 1M but is below the threshold already at 4K. 13 tasks, 4 families Retrieval (NIAH ×8) multi-key, multi-value, multi-query, distractor needles Multi-hop tracing follow X1 = 123, X2 = X1, … Aggregation (CWE, FWE) count words over the whole input QA with distractors SQuAD / HotpotQA, padded Length and difficulty are knobs; 500 examples per length. Claimed (outline) vs effective (filled) Gemini-1.5-Pro 1M / >128K GPT-4 128K / 64K Llama3.1-70B 128K / 64K Qwen2-72B 128K / 32K Yi-34B 200K / 32K Mistral-v0.2 7B 32K / 16K DBRX 32K / 8K LWM 7B 1M / <4K 4K32K128K1M effective = longest length scoring above 85.6 (Llama-2-7B at 4K); paper Table 3, log scale
Original sketch. Left: RULER's four task families. Right: claimed versus effective context length for eight of the 17 models, from Table 3, on a log scale.
  • Table 3 (claimed / effective; score at 4K → 128K): Gemini-1.5-Pro 1M / >128K, 96.7 → 94.4. GPT-4 128K / 64K, 96.6 → 81.2. Llama3.1-70B 128K / 64K, 96.5 → 66.6. Qwen2-72B 128K / 32K, 96.9 → 53.7. Mistral-v0.2 7B 32K / 16K, 93.6 → 13.8. DBRX 32K / 8K, 95.1 → 0.0.
  • Local open-weight models use the reported vLLM/BF16 setup with greedy decoding (8 A100s); GPT-4 and Gemini-1.5-Pro are accessed through provider APIs, so do not assume control of closed models’ serving precision or hardware. Nearly perfect passkey and vanilla NIAH scores (Appendix E) contrast with the RULER drop.
  • §5 (Yi-34B-200K up to 256K): about 40 points lost with a context full of distractor needles; about 15 points lost going from 1 to 8 queries; over 80% of CWE outputs at 128K copy the one-shot example; QA drifts towards the no-context answer.
  • §6: larger Yi models degrade less; LWM-1M is worse than LWM-512K at 256K.
  • One number per length, with no control over where the key information sits (the authors list this).
  • The proxies are not validated against realistic long-context tasks; the authors call RULER a behavioural check.
  • Short-context ability is not evaluated separately, and the 85.6 threshold ties effective length to one old model.
  • Open: an effective-length measure for retrieval-heavy prompts built from real corpora, with graded relevance instead of synthetic needles.
  • Before: Lost in the middle for position effects at short lengths.
  • Next: NoLiMa removes literal overlap; Context Rot holds task difficulty fixed while length grows.
  • Making windows longer: YaRN and RoPE; Mamba as the non-Transformer alternative tested here.
  • Serving: RULER runs its open-weight models on vLLM, whose paged KV cache makes 128K-token evaluation practical.
  • IR benchmarks: BrowseComp-Plus and FRAMES test long, retrieval-heavy contexts in realistic settings.

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    GPT-4 scores 96.6, 96.3, 95.2, 93.2, 87.0 and 81.2 at 4K to 128K on RULER. Compute its weighted averages with weights rising linearly with length (1 to 6) and falling linearly (6 to 1), and its effective length against the 85.6 threshold. Then explain why Qwen2-72B ranks 9th under the increasing weights but 4th under the decreasing ones.

    What a strong answer covers
    • Increasing: (96.6·1 + 96.3·2 + 95.2·3 + 93.2·4 + 87.0·5 + 81.2·6) / 21 = 1869.8 / 21 ≈ 89.0, matching Table 3.
    • Decreasing: (96.6·6 + 96.3·5 + 95.2·4 + 93.2·3 + 87.0·2 + 81.2·1) / 21 = 1976.7 / 21 ≈ 94.1, matching Table 3.
    • Effective length: 87.0 at 64K is above 85.6 and 81.2 at 128K is below, so 64K, half the claimed 128K.
    • Qwen2-72B is the best of all at 4K (96.9) but collapses to 79.8 at 64K and 53.7 at 128K. Weights that favour short inputs reward its short-context strength; weights that favour long inputs punish the collapse.
    • Lesson: one leaderboard number hides the length profile. Choose the weighting from your own length distribution, as the paper suggests.
  2. Mechanism

    Explain why a model can score nearly perfectly on vanilla needle-in-a-haystack and passkey retrieval yet degrade on RULER. For each of the four task families, state which ability it adds beyond finding one literal string, and how the task is scored.

    What a strong answer covers
    • Vanilla NIAH needs one exact match between the question and a single needle in unrelated text, which a model can solve by literal lookup.
    • Retrieval variants add multiple keys (hard distractor needles), multiple values for one key, multiple queries and different needle types (words, numbers, UUIDs), testing precision and completeness.
    • Multi-hop tracing (variable tracking) follows chains like X1 = 12345, X2 = X1, which tests tracking an entity through many hops, a proxy for coreference.
    • Aggregation (common and frequent word extraction) asks for the most frequent words over the whole input, so relevant information is spread out, a proxy for summarisation. Frequent-word difficulty is set by the α of a Zeta distribution.
    • QA inserts gold SQuAD or HotpotQA paragraphs among sampled distractor paragraphs, so the query matches fuzzily rather than literally. All tasks use an answer prefix and recall-based accuracy, with 500 examples per length.
  3. What if…

    Section 5 stresses Yi-34B-200K up to 256K tokens, and Section 6 varies training context length, model size and architecture. Summarise what each analysis shows and which failure mode you would expect most in a RAG reader.

    What a strong answer covers
    • Distractors: filling the context with irrelevant needles costs Yi about 40 points at 256K; it often returns values near the target, suggesting coarse location without precision.
    • Multiple items: going from 1 to 8 queries costs about 15 points; with several values per key Yi returns duplicates instead of the full set.
    • Copying: over 80% of Yi's CWE outputs at 128K copy the one-shot example. In QA, Yi drifts towards its no-context answers, i.e. it falls back on parametric knowledge.
    • Training length helps overall but not consistently (LWM-1M is worse than LWM-512K at 256K); larger Yi models degrade less; RWKV-v5 and Mamba-2.8B lag the Llama2-7B baseline even at 4K.
    • For a RAG reader, the QA and distractor results matter most: topically similar passages act as hard distractors, and the model may answer from memory instead of the passages.
  4. Critique

    The effective length is defined as the longest length whose 13-task average beats Llama2-7B at 4K (85.6). Critique this definition and RULER's synthetic design as a guide for choosing a model for 64K-token RAG prompts. Use the limitations the authors themselves list.

    What a strong answer covers
    • The threshold is arbitrary and absolute. A model that is weak at 4K can never have a long effective length, and averaging 13 tasks lets strong retrieval scores hide weak aggregation scores.
    • No position control: RULER reports one number per length, so it cannot show lost-in-the-middle effects, which matter for passage ordering.
    • No validated link to realistic long-context tasks: the authors say RULER is a behavioural check and should not be preferred over realistic settings.
    • Many needles still share words with the question; NoLiMa later removes this overlap and finds even shorter effective lengths.
    • For a RAG choice, run the QA family with your own corpus as the haystack, at your real prompt lengths, and also check short-context quality (which RULER does not evaluate separately).
  5. Design

    Design a RULER-style benchmark for listwise LLM rerankers that read 50–200 candidate passages in one prompt. Specify the haystack, the needles, the difficulty knobs and the metric, and say how you would define an effective number of candidates.

    What a strong answer covers
    • Haystack: real retrieved candidates for real queries (e.g. from BM25 plus a dense retriever), so distractors are topically close, unlike essay haystacks.
    • Needles: passages with graded relevance labels, inserted at controlled positions. Knobs: number of candidates, number of relevant passages, lexical overlap between query and relevant passage, and distractor similarity.
    • Metric: nDCG@10 of the output ranking, plus recall of all relevant passages, reported by position and by list length.
    • Effective number of candidates: the largest list size where nDCG@10 stays above the same model's score on a short list (e.g. 20), or above a fixed cross-encoder baseline.
    • Generate many instances per setting (the paper uses 500 per length) and keep the generator public, so new models can be tested without leakage.
  6. Connect

    Place RULER between Lost in the Middle and NoLiMa: what does each measure that the others do not, and how would you combine all three to decide how many retrieved passages to give a reader model?

    What a strong answer covers
    • Lost in the Middle varies the position of one gold passage among real retrieved passages at a few thousand tokens; it measures position sensitivity, not length limits.
    • RULER varies length and task type with synthetic data up to 128K and gives an effective length, but averages over positions.
    • NoLiMa removes lexical overlap between question and needle, so it measures latent association; effective lengths shrink further (e.g. GPT-4o to 8K).
    • Combined recipe: take the shortest effective length of the three as the budget, order passages to avoid the middle, and prefer passages with real semantic support over keyword overlap.

Done with this page?

Status