mlsanityData to 14 Oct 2026

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

arXiv 2505.02881 ↗First posted 5 May 2025cs.LG cs.AIcited by 21

On the map: LLM reasoning → Reasoning for agents, planning and code

Abstract (arXiv)

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 (≈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 (≈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.

Key facts. Cited by 21 papers in the map (data through 14 Oct 2026). Placed in Reasoning for agents, planning and code, one of 17 directions in LLM reasoning. Builds on 26 of its 32 references that are in the map. First posted on arXiv 5 May 2025.

Builds on

26 of 32 references.

References · 26

  1. 2021Training Verifiers to Solve Math Word Problemscited by 10,109
  2. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  3. 2020Measuring Massive Multitask Language Understandingcited by 7,963
  4. 2021Measuring Mathematical Problem Solving With the MATH Datasetcited by 5,371
  5. 2019HellaSwag: Can a Machine Really Finish Your Sentence?cited by 4,100
  6. 2021Program Synthesis with Large Language Modelscited by 3,637
  7. 2017TriviaQA: A Large Scale Distantly Supervised Challenge Dataset for Reading Comprehensioncited by 2,955
  8. 2018Can a Suit of Armor Conduct Electricity? A New Dataset for Open Book Question Answeringcited by 2,164
  9. 2019Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelismcited by 1,868
  10. 2022Challenging BIG-Bench Tasks and Whether Chain-of-Thought Can Solve Themcited by 1,807
  11. 2018Know What You Don't Know: Unanswerable Questions for SQuADcited by 1,554
  12. 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,391
14 more
  1. 2021Efficient Large-Scale Language Model Training on GPU Clusters Using Megatron-LMcited by 632
  2. 2024BigCodeBench: Benchmarking Code Generation with Diverse Function Calls and Complex Instructionscited by 546
  3. 2022The Stack: 3 TB of permissively licensed source codecited by 359
  4. 2024Magpie: Alignment Data Synthesis from Scratch by Prompting Aligned LLMs with Nothingcited by 346
  5. 2024Rephrasing the Web: A Recipe for Compute and Data-Efficient Language Modelingcited by 161
  6. 2024Nemotron-CC: Transforming Common Crawl into a Refined Long-Horizon Pretraining Datasetcited by 160
  7. 2024GSM-Plus: A Comprehensive Benchmark for Evaluating the Robustness of LLMs as Mathematical Problem Solverscited by 158
  8. 2024Continual Pre-Training for Cross-Lingual LLM Adaptation: Enhancing Japanese Language Capabilitiescited by 111
  9. 2021It's All in the Heads: Using Attention Heads as a Baseline for Cross-Lingual Transfer in Commonsense Reasoningcited by 69
  10. 2024On the Diversity of Synthetic Data and its Impact on Training Large Language Modelscited by 59
  11. 2025MegaMath: Pushing the Limits of Open Math Corporacited by 51
  12. 2024InfiMM-WebMath-40B: Advancing Multimodal Pre-Training for Enhanced Mathematical Reasoningcited by 36
  13. 2023LLM-Assisted Code Cleaning For Training Accurate Code Generatorscited by 27
  14. 2024Building a Large Japanese Web Corpus for Large Language Modelscited by 11

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 8; 2026: 13.

21 papers.

Sort:

By area:

  1. 2025Kimi K2: Open Agentic Intelligencecited by 567
  2. 2025Nemotron 3 Nano: Open, Efficient Mixture-of-Experts Hybrid Mamba-Transformer Model for Agentic Reasoningcited by 104
  3. 2025Diffusion Language Models are Super Data Learnerscited by 48
  4. 2025Jet-Nemotron: Efficient Language Model with Post Neural Architecture Searchcited by 41
  5. 2025Recycling the Web: A Method to Enhance Pre-training Data Quality and Quantity for Language Modelscited by 31
  6. 2025textttDroid: A Resource Suite for AI-Generated Code Detectioncited by 9
  7. 2026Self-Improving Pretraining: using post-trained models to pretrain better modelscited by 6
  8. 2026Proxy Compression for Language Modelingcited by 3
  9. 2025PCMind-2.1-Kaiyuan-2B Technical Reportcited by 2
  10. 2026Decouple Searching from Training: Scaling Data Mixing via Model Merging for Large Language Model Pre-trainingcited by 2
  11. 2026AICD Bench: A Challenging Benchmark for AI-Generated Code Detectioncited by 2
  12. 2026EstLLM: Enhancing Estonian Capabilities in Multilingual LLMs via Continued Pretraining and Post-Trainingcited by 1
9 more
  1. 2026Bridging Generation and Training: A Systematic Review of Quality Issues in LLMs for Codecited by 1
  2. 2026Which Models Are Our Models Built On? Auditing Invisible Dependencies in Modern LLMscited by 1
  3. 2026Detecting Functional Memorization in Code Language Modelscited by 1
  4. 2026A Sovereign, Open-Source Foundation Model for German and Englishcited by 1
  5. 2026DataOrchestra: Learning to Orchestrate Per-Example Curation of Pretraining Datacited by 1
  6. 2026Puro-2B: Poor Lab's Qwen2-1.5B Trained on RTX 5090 within 5090cited by 1
  7. 2025Beyond Repetition: Text Simplification and Curriculum Learning for Data-Constrained Pretrainingcited by 0
  8. 2026Synthetic Rewriting as a Quality Multiplier: Evidence from Portuguese Continued Pretrainingcited by 0
  9. 2026Fisher-Guided Submodular Data Selection for Continual Pre-Training of Large Language Modelscited by 0

Similar, not cited

Close in wording, no citation either way

  1. 2024Don't Transform the Code, Code the Transforms: Towards Precise Code Rewriting using LLMs
  2. 2025On Code-Induced Reasoning in LLMs
  3. 2024InverseCoder: Self-improving Instruction-Tuned Code LLMs with Inverse-Instruct
  4. 2026CodeEval: A pedagogical approach for targeted evaluation of code-trained Large Language Models
  5. 2025Seed-Coder: Let the Code Model Curate Data for Itself
  6. 2025LeetCodeDataset: A Temporal Dataset for Robust Evaluation and Efficient Training of Code LLMs
  7. 2024Cookbook: A framework for improving LLM generative abilities via programmatic data generating templates
  8. 2025Are Large Language Models Robust in Understanding Code Against Semantics-Preserving Mutations?