arXiv(opens in a new tab)cs.CLApr 2024Cited by 155 papers on PaperVantageClassic Paper

Manuscript Offprint

arXiv:2404.06654

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

Cheng-Ping Hsieh, Simeng Sun, Samuel Kriman, Shantanu Acharya, Dima Rekesh, Fei Jia, Yang Zhang, Boris Ginsburg

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

The needle-in-a-haystack (NIAH) test, which examines the ability to retrieve a piece of information (the "needle") from long distractor texts (the "haystack"), has been widely adopted to evaluate long-context language models (LMs). However, this simple retrieval-based test is indicative of only a superficial form of long-context understanding. To provide a more comprehensive evaluation of long-context LMs, we create a new synthetic benchmark RULER with flexible configurations for customized sequence length and task complexity. RULER expands upon the vanilla NIAH test to encompass variations with diverse types and quantities of needles. Moreover, RULER introduces new task categories multi-hop tracing and aggregation to test behaviors beyond searching from context. We evaluate 17 long-context LMs with 13 representative tasks in RULER. Despite achieving nearly perfect accuracy in the vanilla NIAH test, almost all models exhibit large performance drops as the context length increases. While these models all claim context sizes of 32K tokens or greater, only half of them can maintain satisfactory performance at the length of 32K. Our analysis of Yi-34B, which supports context length of 200K, reveals large room for improvement as we increase input length and task complexity. We open source RULER to spur comprehensive evaluation of long-context LMs.

1 Introduction

Recent advancements in AI system engineering (Dao et al., 2022; Jacobs et al., 2023; Fu et al., 2024) and language model designs (Chen et al., 2023; Xiong et al., 2023) have enabled efficient scaling up of context length for language models (Liu et al., 2024a; Young et al., 2024). Previous works (AI21, 2024; X.AI, 2024; Reid et al., 2024; Anthropic, 2024) commonly adopt synthetic tasks, such as passkey retrieval (Mohtashami & Jaggi, 2023) and needle-in-a-haystack (Kamradt, 2023) to evaluate long-context LMs. However, these evaluations are used inconsistently across works and reveal merely the retrieval capability, failing to gauge other forms of long-context understanding.

In this work, we propose RULER, a new benchmark to evaluate long-context modeling capabilities for language models. RULER contains four task categories to test behaviors (Ribeiro et al., 2020) beyond simple retrieval from context:

  1. Retrieval: we extend the needle-in-a-haystack (Kamradt, 2023, NIAH) test to evaluate retrieval capability with diverse types and quantities of needles.

  2. Multi-hop Tracing: we propose variable tracking, a minimal proxy task for coreference chain resolution to check the behavior of tracing entities with multi-hop connections.

  3. Aggregation: we propose common/frequent words extraction, proxy tasks for summarization to test the ability to aggregate relevant information that spans long-range context.

∗^{*} Authors contributed equally.

Benchmark & TaskAvg LenTypeDiverse TasksMin. Parametric KnowledgeControllable Context
ZeroSCROLLS~10krealistic✓✕✕
L-Eval~8krealistic✓✕✕
BAMBOO~16krealistic✓✓✕
LongBench~8khybrid✓✕✕
LooGLE~20khybrid✓✓✕
InfiniteBench~200khybrid✓✓✕
Needle-in-a-haystack (NIAH)anysynthetic✕✓✓
Passkey / Line / KV Retrievalanysynthetic✕✓✓
RULER (Ours)anysynthetic✓✓✓

Table 1: Comparison between existing long-context benchmarks and RULER. “Realistic” type refers to human-annotated while “synthetic” type refers to auto-generated. RULER includes diverse task domains beyond retrieval, reduces reliance on parametric knowledge with synthetic input, and offers flexibility to control the contexts for different sequence lengths and task complexities. In RULER, contexts can be adjusted by changing the volume or placement of relevant and distracted information.

  1. Question Answering: we add distracting information to the input of existing short-context QA datasets to evaluate question answering capability at various context sizes.

Compared to existing realistic benchmarks (Table 1), RULER consists solely of synthetic tasks, which offer the flexibility to control sequence length and task complexity. The synthetic input in RULER reduces reliance on parametric knowledge, which interferes with the utilization of long-context input in realistic tasks (Shaham et al., 2023; Bai et al., 2023).

Using RULER, we benchmark Gemini-1.5 (Reid et al., 2024), GPT-4 (OpenAI: Josh Achiam et al., 2023), and 15 open-source models with context length ranging from 4k to 128k. Despite achieving nearly perfect performance on the vanilla NIAH test, almost all models exhibit large degradation on more complex tasks in RULER as sequence length increases. While all models claim context size of 32k tokens or greater, our results indicate that only half of them can effectively handle sequence length of 32K by exceeding a qualitative threshold. Moreover, almost all models fall below the threshold before reaching the claimed context lengths. To obtain fine-grained model comparisons, we aggregate performance from 4k to 128k with two weighted average scores where the weights simulate the length distribution of real-world use cases. The top two models - Gemini-1.5 and GPT-4, consistently outperform other models regardless of the chosen weighting scheme.

We further analyze Yi-34B, which claims context length of 200K and achieves reasonably good performance on RULER among open-source models. Our results demonstrate large degradation in Yi's performance as we increase input length and task complexity. At large context sizes, Yi-34B often returns incomplete answers and fails to precisely locate the relevant information. Furthermore, we observe two behaviors emerging with the scaling of context size across multiple models: the increased reliance on parametric knowledge and the increased tendency to copy from context for non-retrieval tasks. Our additional ablations demonstrate that training on longer sequences does not always lead to better performance on RULER, and that larger model sizes positively correlate with better long-context capabilities. Finally, we show that non-Transformer architectures, such as RWKV and Mamba, still lag behind Transformer by large margins on RULER.

Our contributions are as follows:

  • We propose a new benchmark RULER for evaluating long-context language models via synthetic tasks with flexible configurations.

  • We introduce new task categories, specifically multi-hop tracing and aggregation, to test behaviors other than retrieval from long context.

  • We evaluate 17 long-context LMs using RULER and perform analysis across models and task complexities.

We open source RULER to spur future research in long-context language models.1^{1}

1^{1}https://github.com/hsiehjackson/RULER

References (86)

Cited by (155)