Scaling Instruction-Tuned LLMs to Million-Token Contexts via Hierarchical Synthetic Data Generation

Linda He, Jue Wang, Maurice Weber, Shang Zhu, Ben Athiwaratkun, Ce Zhang

TL;DR

This paper introduces a novel, highly scalable synthetic data generation pipeline that extends the context window of Large Language Models (LLMs) up to 1 million tokens. By leveraging short-context models to hierarchically generate and order diverse question-answer pairs across concatenated documents, the authors successfully scale LLaMA-3.1-8B-Instruct to a 1M token context while preserving robust performance on standard short-context tasks.

What Problem Does This Paper Address?

While modern LLMs theoretically support long context windows through architectural tweaks or positional embedding extensions (like RoPE scaling), they frequently fail in practice on long-range reasoning tasks. A primary bottleneck is the severe scarcity and high cost of high-quality, long-context instruction-tuning data; currently, no open-source instruction datasets exceed 100K tokens.

Human annotation at this scale is prohibitively expensive and logistically challenging. To bridge this gap, the authors address how to synthetically generate high-quality, logically coherent, and diverse long-context instruction data without being constrained by the length of available real-world data.

Methods

The core innovation is a bifurcated synthetic data generation pipeline that uses capable short-context models (like Qwen-2-72B-Instruct) to bootstrap ultra-long context data.

Figure 1: High-level overview over our approach to automatically generate QA pairs for long context documents. (1) In the first step, we split a document into small and medium chunks which are then (2) summarized by an off-the-shelf LLM requiring only smaller context windows. In (3) we sample summaries at different localities in a hierarchical manner, balancing local and global views of the original document. In (4) we generate questions based on the sampled summaries. In the right panel, we show a subset of prompts used to generate diverse and complex questions, given the sampled summaries.

The pipeline relies on three main strategies:

  1. Hierarchical Question Ordering: Long documents are broken down into medium (12K tokens) and small (4K tokens) chunks. An off-the-shelf LLM summarizes these chunks. Questions are then generated using a structured "exploration-exploitation" sampling strategy—starting from global summaries, moving to medium chunks, and then delving into specific small chunks to ensure logical progression and continuity.
  2. Diverse Question Pool: The pipeline generates multiple question types, including hierarchy-aware, local-specific, complex reasoning (temporal, thematic, character-based), and multi-hop questions that span 2–4 chunks to force cross-chunk reasoning.
  3. Multi-Document Integration: To scale to arbitrary lengths (up to 1M tokens), multiple documents are concatenated. The pipeline injects cross-document questions and periodically revisits earlier documents to ensure the model maintains contextual continuity across massive token spans.

For model training, the authors employ a stepwise RoPE scaling strategy, progressively fine-tuning the base model through checkpoints at 180K, 350K, 650K, and finally 1M tokens.

Datasets

  • Training Data: The authors utilized the Together long books dataset, processing it into approximately 1.4 billion tokens. This was distributed across progressive training stages: 2,000 samples at 180K tokens, 1,280 samples at 350K tokens, 600 samples at 650K tokens, and 200 samples at 1M tokens. A total of 582,900 QA pairs were synthetically generated.
  • Evaluation Benchmarks:
  • RULER: A synthetic benchmark testing complex long-context behaviors (e.g., multi-hop reasoning, tracking) up to 1M tokens.
  • InfiniteBench: Evaluates tasks exceeding 100K tokens (key-value retrieval, long QA, summarization).
  • LongBench: Tests medium-context capabilities (~10K tokens).
  • MMLU: Evaluates general, short-context domain knowledge to monitor capability regression.

Key Insights and Ideas

  • Bootstrapping Long Context from Short Context: A key "aha" moment is that an LLM doesn't need a long context window to generate long-context training data. By smartly chunking documents and prompting the generator model to synthesize across summaries, short-context models can effectively build million-token datasets.
  • Structure Matters More Than Randomness: Systematic ablation studies revealed that a fixed number of structured, hierarchically ordered questions significantly outperforms randomized question counts. Maintaining a strict logical flow prevents the model from getting confused during long-sequence training.
  • Mitigating the Long-Context Tax: Typically, expanding an LLM's context window degrades its performance on short-context tasks (a phenomenon known as catastrophic forgetting or regression). This hierarchical synthetic tuning approach acts as a regularizer, achieving top-tier long-context reasoning while keeping short-context capabilities intact.

Key Results

The resulting model, extended from LLaMA-3.1-8B-Instruct, demonstrated exceptional performance:

  • RULER Benchmark: The 1M token model achieved an effective context length that significantly outperformed the zero-shot RoPE-scaled base model and commercial baselines like Gradient AI's 1M model (gradientai/Llama-3-8B-Instruct-Gradient-1048k).
  • InfiniteBench: The synthetic data-tuned models consistently beat the base LLaMA model and Gradient AI. For instance, the 180K model scored an average of 59.45 vs. the base model's 51.31 and Gradient AI's 41.04. Significant gains were observed in key-value retrieval (Retrieve.KV).
  • General Capabilities Preservation: On MMLU, the 1M model retained a score of 65.08 (compared to the base model's 68.21), whereas Gradient AI's model degraded severely down to 60.48.

Limitations and Future Work

  • Under-training at Extreme Scale: The authors note that their 650K and 1M models suffered minor performance drops due to being slightly under-trained. This was caused by the massive compute time required and communication overheads during multi-node NCCL training.
  • Lack of Code Data: Coding tasks were excluded from evaluation because the synthetic pipeline focused entirely on natural language books and documents.
  • Self-Evolutionary Frameworks: The authors point to a promising future direction: developing a self-evolutionary strategy where the short-context model autonomously diversifies, adapts, and evolves its own prompts and long-context data without human-curated prompt templates.

Summary updated

Abstract

Large Language Models (LLMs) struggle with long-context reasoning, not only due to the quadratic scaling of computational complexity with sequence length but also because of the scarcity and expense of annotating long-context data. There has been barely any open-source work that systematically ablates long-context data, nor is there any openly available instruction tuning dataset with contexts surpassing 100K tokens. To bridge this gap, we introduce a novel post-training synthetic data generation strategy designed to efficiently extend the context window of LLMs while preserving their general task performance. Our approach scalably extends to arbitrarily long context lengths, unconstrained by the length of available real-world data, which effectively addresses the scarcity of raw long-context data. Through a step-by-step rotary position embedding (RoPE) scaling training strategy, we demonstrate that our model, with a context length of up to 1M tokens, performs well on the RULER benchmark and InfiniteBench and maintains robust performance on general language tasks.
BibTeX
@inproceedings{he2025scaling,
  author = {Linda He and Jue Wang and Maurice Weber and Shang Zhu and Ben Athiwaratkun and Ce Zhang},
  title = {{Scaling Instruction-Tuned LLMs to Million-Token Contexts via Hierarchical Synthetic Data Generation}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=BkwCrIsTbR},
}
Figure