通过重写训练数据,显著提升大模型在代码和数学上的表现。
Rewriting Pre-Training Data Boosts LLM Performance in Math and Code
- 用四阶段流程重写公开代码与数学题,保留并优化低质量数据。
- 在500亿词元预算下,代码通过率提升17.0,数学准确率提升12.4。
- 开源数据集与方法,可复现且适用于其他模型和任务。
大型语言模型在程序合成和数学推理方面的性能,受限于预训练语料的质量。本文推出两个开源预训练数据集(遵循 Llama 3.3 Community License),通过系统性重写公共数据显著提升模型表现。SwallowCode(约161亿词元)对 The-Stack-v2 中的 Python 代码片段进行四阶段处理:语法验证、pylint 风格过滤,以及两阶段 LLM 重写,确保风格一致并转化为自包含、算法高效的示例。相比以往仅排除或有限变换的方法,本方法采用“转化并保留”策略,最大化数据价值。SwallowMath(约23亿词元)则改进 Finemath-4+ 数据,去除冗余内容,恢复上下文,并将解题过程重构成简洁的分步解释。在固定500亿词元训练预算下,持续预训练 Llama-3.1-8B 模型,使用 SwallowCode 可使 HumanEval 的 pass@1 提升17.0,HumanEval+ 提升16.1,超越基线模型;使用 SwallowMath 可使 GSM8K 准确率提升12.4,MATH 提升7.6。消融实验表明各阶段均有增量贡献,其中重写环节收益最大。我们开放数据集、提示、检查点与流水线代码,保障可复现性,并提供可迁移的‘转化并保留’方法论,适用于其他基础模型与大模型重写场景。
原文摘要 · Abstract (English)
The performance of large language models (LLMs) in program synthesis and mathematical reasoning is fundamentally limited by the quality of their pre-training corpora. We introduce two openly licensed pre-training datasets, released under the Llama 3.3 Community License, that significantly enhance LLM performance by systematically rewriting public data. SwallowCode ($\approx$16.1 billion tokens) refines Python snippets from The-Stack-v2 through a novel four-stage pipeline: syntax validation, pylint-based style filtering, and a two-stage LLM rewriting process that enforces style conformity and transforms snippets into self-contained, algorithmically efficient examples. Unlike prior methods that rely on exclusionary filtering or limited transformations, our transform-and-retain approach refines low-quality code, maximizing data utility. SwallowMath ($\approx$2.3 billion tokens) enhances Finemath-4+ by removing boilerplate, restoring context, and reformatting solutions into concise, step-by-step explanations. Within a fixed 50 billion token training budget, continual pre-training of Llama-3.1-8B with SwallowCode boosts pass@1 by +17.0 on HumanEval and +16.1 on HumanEval+ compared to Stack-Edu, surpassing the baseline model's code generation capabilities. Similarly, substituting SwallowMath yields +12.4 accuracy on GSM8K and +7.6 on MATH. Ablation studies confirm that each pipeline stage contributes incrementally, with rewriting yielding the largest gains. By releasing datasets, prompts, checkpoints, and pipeline code, we ensure reproducibility and provide a transferable transform-and-retain methodology that can be adapted to other base models and LLM rewriting setups.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。