Manuscript Offprint

arXiv:2610.24469

Which Long Documents Matter? A Controlled Study of Data Selection for Context Extension

Junlong Jia, Jiang Zhou, Xing Wu, Chaochen Gao Tinghao Yu, Feng Zhang, Lilin Wang

Junlong Jia, Jiang Zhou, Xing Wu †^{\dagger}, Chaochen Gao

Tinghao Yu †^{\dagger}, Feng Zhang, Lilin Wang

Hunyuan Team, Tencent

{ucaswu,maxwellyu}@tencent.com

Natural long documents are widely used for context extension, but which selection pipelines are effective remains unclear. We conduct a controlled comparison on Qwen2.5-3B at 128K under matched 6B-token continued-training budgets. Random sampling of natural long documents (random-long) outperforms repacking at longer evaluation lengths. Within the same candidate pool, selecting documents with high LongPPL key-token density yields further gains, unlike the evaluated generic-quality and LLM-judge selectors. We introduce truncLongPPL to reduce scoring cost by computing key-token density over a truncated prefix. At 128K, scoring the first half of the reference span yields downstream performance close to full-span scoring with a measured 2.28×2.28\times end-to-end scoring speedup. Across three training seeds, truncLongPPL achieves the highest mean scores among evaluated pipelines, exceeding random-long by 4.54 points on validation HELMET and 3.28 on held-out RULER, with gains most consistent in retrieval. At a 256K target context, it gains 2.82 average RULER points over random-long on Qwen2.5-3B. In short/long mixed training across Qwen2.5-3B, Qwen3-8B, and OLMo 3-7B, it gains 1.47–7.31 average RULER points over random-long mixing, with seven-task short-context averages within 0.23 points of the corresponding baselines. After supervised fine-tuning (SFT), Qwen3-8B and OLMo 3-7B models trained with selected long documents outperform their random-long counterparts by 1.13–1.67 points on LongBench v2 and 0.62–1.44 points on MRCR.

1. Introduction

Long-context extension commonly involves continued training at longer sequence lengths (Gao et al., 2025c; Liu et al., 2024; Sun et al., 2026; Yang et al., 2025). Natural long documents are useful for this stage because they can contain cross-section structure, delayed references, and distributed evidence (Gao et al., 2025c; Olmo et al., 2025). However, length alone does not guarantee useful supervision: some documents contain substantial cross-passage dependencies, whereas others largely consist of locally coherent but independent passages (Chen et al., 2024; Deng et al., 2025; Fang et al., 2025). This raises two practical questions: do natural long documents offer benefits over repacking, and which selection pipelines improve on random sampling?

Existing selection pipelines use different signals, ranging from generic-quality proxies such as perplexity (PPL) and gzip compressibility to dependency-aware signals based on model judgments or likelihood changes induced by additional context (Chen et al., 2024; Deng et al., 2025; Fang et al., 2025; Olmo et al., 2025). Their findings are difficult to compare because corpora, scoring models, target contexts, training budgets, and mixture ratios vary across studies. OLMo 3, for example, evaluates document-level filters derived from LongPPL key-token statistics but reports no clear advantage over gzip in its setting (Olmo et al., 2025). These differences in experimental settings motivate a controlled comparison under shared training and evaluation conditions.

†^{\dagger}Corresponding authors.

We conduct this comparison on Qwen2.5-3B (Yang et al., 2024) at 128K with matched 6B-token continued-training budgets. We first compare repacking with random sampling of natural long documents, then evaluate generic-quality, LLM-judge, and likelihood-based selection pipelines within a fixed natural-long candidate pool. HELMET (Yen et al., 2024) determines the selection configuration, while RULER (Hsieh et al., 2024) is held out for evaluation; seven short-context tasks assess capability retention. These comparisons evaluate complete pipelines and identify LongPPL-based key-token density as a promising selection criterion, motivating a closer examination of its selectivity and computational cost.

To understand when LongPPL-based selection helps, we first examine how the retained density range and filtering strength affect downstream performance. Full-span scoring is expensive at corpus scale, so we then test whether shorter prefixes preserve the selection benefit at lower cost. This leads to truncLongPPL, which computes key-token density over a truncated prefix. In the controlled 128K study, front-half scoring yields downstream scores close to full-span scoring while reducing scoring cost. Capability-level analysis further shows that the most consistent gains are in retrieval, with less uniform benefits for other long-context capabilities.

We further validate selection at a 256K target context on Qwen2.5-3B under the same training-token budget. The short-context decline observed during continued training also motivates experiments that mix high-quality short data with natural long documents. We compare random and selected long data within these mixtures, extend the evaluation to Qwen3-8B (Yang et al., 2025) and OLMo 3-7B (Olmo et al., 2025), and use LongBench v2 and MRCR to assess whether the selection gains persist after supervised fine-tuning (SFT).

References (85)

  • Yushi Bai, Shangqing Tu, Jiajie Zhang, Hao Peng, Xiaozhi Wang, Xin Lv, Shulin Cao, Jiazheng Xu, Lei Hou, Yuxiao Dong, et al. Longbench v2: Towards deeper understanding and reasoning on realistic long-context multitasks. arXiv preprint arXiv:2412.15204, 2024. (opens arXiv in a new tab)
  • Reasoning about physical commonsense in natural language
  • Ladm: Long-context training data selection with attention-based dependency measurement for llms
  • Long context is not long at all: A prospector of long-dependency data for large language models
  • Think you have Solved Question Answering? Try ARC, the AI2 Reasoning Challenge
  • Flashattention: Fast and memory-efficient exact attention with io-awareness
  • Beyond length: Quantifying long-range information for long-context llm pretraining data
  • What is wrong with perplexity for long-context language modeling? In International Conference on Learning Representations, volume 2025, pages 94541–94563, 2025
  • QUEST: Query-centric data synthesis approach for long-context scaling of large language model (opens arXiv in a new tab)
  • Longmagpie: A self-synthesis method for generating large-scale long-context instructions (opens arXiv in a new tab)
  • NExtLong: Toward effective long-context training without long documents (opens arXiv in a new tab)
  • The language model evaluation harness, 2024b
  • How to train long-context language models (effectively)
  • RULER: What's the Real Context Size of Your Long-Context Language Models?
  • Entropylong: Effective long-context training via predictive uncertainty (opens arXiv in a new tab)
  • Resource-efficient long-context data synthesis for llms
  • Policylong: Towards on-policy context extension (opens arXiv in a new tab)
  • Efficient memory management for large language model serving with pagedattention
  • DeepSeek-V3 Technical Report
  • Logiqa: A challenge dataset for machine reading comprehension with logical reasoning
  • Team Olmo, Allyson Ettinger, Amanda Bertsch, Bailey Kuehl, David Graham, David Heineman, Dirk Groeneveld, Faeze Brahman, Finbarr Timbers, Hamish Ivison, et al. Olmo 3. arXiv preprint arXiv:2512.13961, 2025. (opens arXiv in a new tab)
  • The lambda dataset: Word prediction requiring a broad discourse context
  • Winogrande: An adversarial winograd schema challenge at scale
  • In-context pretraining: Language modeling beyond document boundaries
  • Data foundations of long-context language models: A survey
  • Gemma 4 Technical Report
  • Long context evaluations beyond haystacks via latent structure queries (opens arXiv in a new tab)
  • Longattn: Selecting long-context training data via token-level attention
  • Qwen2.5 Technical Report
  • Qwen3 Technical Report
  • Helmet: How to evaluate long-context language models effectively and thoroughly (opens arXiv in a new tab)
  • Hellaswag: Can a machine really finish your sentence? In Proceedings of the 57th annual meeting of the association for computational linguistics, pages 4791–4800, 2019
  • GLM-5: from Vibe Coding to Agentic Engineering
  • generic-quality, LLM-judge, and likelihood-based long-dependency
  • The random-long pipeline uniformly samples documents from $\mathcal{C}$ without applying a quality or dependency score
  • The top-40% rule selects documents above the global 60th percentile of PPL scores, whereas the middle-40% rule selects documents between the 30th and 70th percentiles
  • We rank documents by the fraction of pairs classified as dependent and select the top 5%; Appendix C gives the exact score definition and the complete user prompt
  • Appendix D gives their score definitions and implementation details
  • The placeholders {head_text} and {tail_text} are replaced by the earlier and later fragment, respectively (each truncated to its leading 512 and trailing 256 tokens, with the middle elided as “…” when longer)
  • To save space, an overly long fragment keeps only its beginning and end, with the middle elided as "..."
  • DEPENDENT (1)
  • this method / the above system / he / it / this parameter / as mentioned earlier
  • we denote our model as M
  • to answer the above / to accomplish that task
  • how to reduce GPU memory usage?
  • that value / the above parameter / under this setting
  • learning rate = 1e-4, batch = 256
  • therefore / thus / then / next / after that / finally
  • mix the reactants and heat to 80C
  • as noted above / as argued earlier / on the contrary / building on this / this confirms the earlier conclusion
  • a long context does not necessarily lower perplexity
  • NOT DEPENDENT (0)
  • same topic / same domain / similar wording / both mention some common-knowledge entity
  • encyclopedic listings, mutually-unreferenced problem lists), even if the same terminology recurs
  • With $\Delta_{ij}=\mathrm{PPL}(c_i)-\mathrm{PPL}(c_i\mid c_j)$ and $q_{ij}=\exp(\Delta_{ij})/\sum_{k<i}\exp(\Delta_{ik})$, dependency specificity for target blocks with at least two possible predecessors ($i\ge 3$) is the normalized inverse entropy
  • We follow Chen et al. (2024) with $(a,b)=(1,1)$
  • For truncLongPPL with prefix fraction $r$, let $T_r = \lfloor rL \rfloor > K$, where $L$ is the nominal target-context reference span and $r$ specifies the prefix fraction
  • The default is $r = 1/2$; $r = 1$ is the full-span reference
  • For the controlled Qwen2.5-3B 128K study, the frozen scoring model $p_{\theta_0}$ is Gemma-4-26B-A4B (base) (Team et al., 2026a), served in bf16 through vLLM (Kwon et al., 2023) with a FlashAttention backend (Dao et al., 2022) on H20 GPUs
  • At $L = 256\mathrm{K}$, the tested prefix fractions $r = 1/4$ and $r = 1/2$ correspond to prefix endpoints of 64K and 128K, respectively
  • Its evaluated LongPPL rules include one-sided bottom-20% removal and symmetric top-and-bottom-20% removal
  • Table 8 shows the same qualitative result as OLMo 3: the two pipelines differ by at most 1.17 points across all evaluated budgets and by at most 0.51 points from 4B tokens onward
  • The former retains high-density documents within a broad
  • ><tr><td rowspan=
  • Their per-document key-token densities are strongly correlated (Pearson $r=0.83$; Spearman $\rho=0.77$)
  • This quantity is the fraction of front-half-selected documents also selected by full-span scoring, not a symmetric agreement measure
  • We also directly measure per-document wall-clock time for the complete scoring pipeline
  • Thresholds from 0.03 to 0.06 form a higher-performing cluster from approximately 6B tokens onward, with generally small subsequent gains
  • At $L = 128\mathrm{K}$, we compare front-half and tail-half windows, the full span, and eight scattered windows totaling half of the reference span (each 8K)
  • Across $\tau \in \{0.03, 0.04, 0.05\}$, validation HELMET differs by approximately one point or less, with no consistent direction
  • We repeat that comparison at the more permissive threshold $\tau = 0.03$
  • At 256K, we compare this with a 64K prefix ($r = 1/4$), which retains the absolute scoring length used by the 128K default
  • >Scoring configuration</td><td>128K training</td><td colspan=
  • Extending the scoring prefix to 128K adds 0.62 point on the average and 0.64 point at the endpoint
  • We assess this shift by resampling documents selected by truncLongPPL to match the domain proportions of the original candidate pool and comparing performance before and after resampling
  • We also include the uncontinued base model (BASE, no long-context extension) as a reference
  • Table 12 gives the mean ± standard deviation over the three runs
  • The 66/34 row reports the rounded summary scores from Section 7.1, while the other ratios assess sensitivity to the mixture ratio
  • >Short:long</td><td colspan=
  • The seven-task short-context averages are close within each pair
  • Continued training uses 256K and 20B tokens, with short:long = 66/34 in the mixed configurations
  • All three evaluation runs per configuration and benchmark are included
  • Its Medium and Long scores improve on random-long by 1.87 and 2.77 points, respectively, while its Short score is lower by 0.73 point
  • The continued-training setting is 256K and 20B tokens, with short:long = 66/34 in the mixed configurations
  • LongBench v2 uses $N = 503$