Beyond Length: Quantifying Long-Range Information for Long-Context LLM Pretraining Data

Haoran Deng, Yingyu Lin, Zhenghao Lin, Xiao Liu, Yizhou Sun, Yian Ma, Yeyun Gong

TL;DR

Training long-context Large Language Models (LLMs) is often inefficient because most "long" text is locally predictable—you don't actually need the beginning of a book to guess the next word in the final chapter. This paper introduces LongFilter, a framework that selects high-quality pretraining data by measuring the "information gain" provided by long-range context. By filtering for true long-distance dependencies, LongFilter leads to superior performance on benchmarks like RULER and LongBench using significantly less data.

The Problem: Sequence Length is a Poor Proxy for Context Quality

We are currently in an "arms race" for context window size, with models supporting 128K, 1M, or even more tokens. To enable these capabilities, researchers typically take a base model and perform "continued pretraining" on long sequences.

However, current data engineering practices harbor a major flaw: sequence length does not guarantee long-context quality. Many long documents are repetitive (like system logs), consist of independent segments (like a collection of short poems), or are predictable from just the last few sentences. Training on this "low-signal" data dilutes the learning process, making it harder for the model to learn true long-range dependencies. The challenge is mathematically identifying data where the "long" part of the context actually matters.

Methods: Quantifying Contextual Gain

The authors propose LongFilter, a framework designed to quantify the "Contextual Gain" of a document.

  1. The Core Metric: The method is rooted in Information Theory, specifically Conditional Mutual Information (CMI). It asks: How much does uncertainty about the next token decrease if the model sees the "long" context versus just the "short" context?
  2. The Scoring Function: Because calculating true CMI is computationally expensive, LongFilter uses a practical surrogate. It compares the model's prediction distributions under two settings:
  3. Short Context ($S$): The immediate preceding tokens (e.g., 4K).
  4. Long Context ($L$): The full extended context (e.g., 64K).
  5. Implementation: Using a pre-trained model (like LLaMA-3-8B), the framework calculates the cross-entropy loss for tokens under both short and long context settings. The "LongFilter Score" is the difference between these losses, weighted by the model's confidence.
Illustration of LongFilter Scoring

By ranking documents by this score and selecting the top 20% for training, LongFilter ensures the model spends its compute budget on sequences where the distant past provides crucial clues for the present.

Key Insights and Ideas

  • "Long-length $\neq$ Long-context": This is the paper's core mantra. A 64K token file of random numbers is long, but it contains zero long-context information gain.
  • The "1-to-2" Step: Previous work focused on a "0-to-1" step (getting the model to simply process long sequences). LongFilter represents a "1-to-2" step: focusing the learning signal specifically on tokens that require long-range understanding.
  • Qualitative Signal: In case studies, academic prose (like a PhD thesis) scored very high because arguments build over many pages. Conversely, LaTeX TikZ code (used for drawing diagrams) scored very low because the tokens are highly repetitive and locally predictable.

Key Results and Data Efficiency

The authors extended LLaMA-3-8B from an 8K context to 64K using LongFilter-selected data from the SlimPajama dataset (ArXiv, Books, and CommonCrawl subsets).

One of the most striking findings is LongFilter's data efficiency. Training on just 1.5B filtered tokens yielded performance comparable to (or better than) training on 3B to 4B unfiltered tokens.

NIAH Recall vs. Trained Tokens
  • Needle-in-a-Haystack (NIAH): On recall tasks, LongFilter models reached scores above 90 much faster than baselines (like ProLong and LongWanjuan) as training progressed.
  • Benchmark Dominance: LongFilter-trained models consistently outperformed baselines across all tested categories on the HELMET evaluation suite.
  • RULER Performance: On the notoriously difficult RULER benchmark, LongFilter achieved an overall score of 78.95 on the Book dataset, significantly higher than the ProLong baseline of 73.35.

Limitations and Future Work

  • Scoring Overhead: While the authors scored their dataset in a single day using 32 H100 GPUs, running a full forward pass (twice, for short and long context) on the entire candidate pool is a non-trivial computational cost.
  • Model Bias: The filtering quality depends heavily on the "teacher" model used for scoring. If the scoring model has blind spots in long-context reasoning, the filter might miss certain types of high-quality data.
  • Future Directions: The authors suggest exploring even larger context windows (e.g., 128K or 1M) and investigating whether the "optimal" data for pretraining shifts as the model's context window grows.

Summary updated

BibTeX
@inproceedings{deng2026beyond,
  author = {Haoran Deng and Yingyu Lin and Zhenghao Lin and Xiao Liu and Yizhou Sun and Yian Ma and Yeyun Gong},
  title = {{Beyond Length: Quantifying Long-Range Information for Long-Context LLM Pretraining Data}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=C9TDQ8Wwx7},
}
Figure