Rewriting Pre-Training Data Boosts LLM Performance in Math and Code

LLM PTSAD LNJR AI4SE Other SE
大型语言模型(LLMs)在程序合成和数学推理方面的表现从根本上受限于其预训练语料库的质量。我们引入了两个开放许可的数据集,这些数据集在 Llama 3.3 社区许可下发布,通过系统性地重写公开数据,显著提升了 LLM 的性能。SwallowCode(约 161 亿 token)通过对 The-Stack-v2 中的 Python 代码片段进行四阶段处理来优化其质量:语法验证、基于 pylint 的风格过滤,以及一个两阶段的 LLM 重写过程,该过程确保代码风格一致,并将代码片段转化为独立且算法高效的示例。与以往依赖排除性过滤或有限转换的方法不同,我们的“转换并保留”方法能够升级低质量代码,最大化数据的使用价值。SwallowMath(约 23 亿 token)通过去除冗余内容、恢复上下文信息,并将解决方案重新格式化为简洁的分步解释,改进了 Finemath-4+ 数据集。在固定的 500 亿 token 训练预算内,使用 SwallowCode 对 Llama-3.1-8B 进行持续预训练,相较于 Stack-Edu,在 HumanEval 上的 pass@1 提升了 +17.0,在 HumanEval+ 上提升了 +17.7,超越了基线模型的代码生成能力。同样地,使用 SwallowMath 替代原有数据集后,在 GSM8K 上的准确率提高了 +12.4,在 MATH 上提高了 +7.6。消融研究表明,每一步处理流程都带来了增量改进,其中重写步骤贡献了最大的提升。所有数据集、提示模板和检查点均已公开,这有助于可复现的研究,并推动 LLM 在专业领域预训练技术的发展。
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 datasets, released under the Llama 3.3 Community License, that significantly enhance LLM performance by systematically rewriting public data. SwallowCode (approximately 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 upgrades low-quality code, maximizing data utility. SwallowMath (approximately 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 +17.7 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 delivering the largest gains. All datasets, prompts, and checkpoints are publicly available, enabling reproducible research and advancing LLM pre-training for specialized domains.
许愿