Data Engineering for Scaling Language Models to 128K Context

Yao Fu, Rameswar Panda, Xinyao Niu, Xiang Yue, Hanna Hajishirzi +2 more
2/12/2026

No official code found. Best implementation: FranxYao/Long-Context-Data-Engineering (498 stars, last commit 2024-03-19).

Abstract

We study the continual pretraining recipe for scaling language models' context lengths to 128K, with a focus on data engineering. We hypothesize that long context modeling, in particular \textit{the ability to utilize information at arbitrary input locations}, is a capability that is mostly already acquired through large-scale pretraining, and that this capability can be readily extended to contexts substantially longer than seen during training~(e.g., 4K to 128K) through lightweight continual pretraining on appropriate data mixture. We investigate the \textit{quantity} and \textit{quality} of the data for continual pretraining: (1) for quantity, we show that 500 million to 5 billion tokens are enough to enable the model to retrieve information anywhere within the 128K context; (2) for quality, our results equally emphasize \textit{domain balance} and \textit{length upsampling}. Concretely, we find that naively upsampling longer data on certain domains like books, a common practice of existing work, gives suboptimal performance, and that a balanced domain mixture is important. We demonstrate that continual pretraining of the full model on 1B-5B tokens of such data is an effective and affordable strategy for scaling the context length of language models to 128K. Our recipe outperforms strong open-source long-context models and closes the gap to frontier models like GPT-4 128K.

View on arXivView PDF

Code Implementations(1)

Implementation of paper Data Engineering for Scaling Language Models to 128K Context

49831PythonJan 31, 20242 years ago

Similar Papers

Cite this paper

@article{fu2026data,
  title  = {Data Engineering for Scaling Language Models to 128K Context},
  author = {Yao Fu and Rameswar Panda and Xinyao Niu and Xiang Yue and Hanna Hajishirzi and Yoon Kim and Hao Peng},
  year   = {2026},
  eprint = {2402.10171},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2402.10171},
  journal = {ICML 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2402.10171.svg)](https://codeofpaper.com/paper/2402.10171)

Discussion