mlsanityData to 7 Oct 2026

MathCoder2: Better Math Reasoning from Continued Pretraining on Model-translated Mathematical Code

arXiv 2410.08196 ↗First posted 10 Oct 2024cs.CL cs.AI cs.CVcited by 39

On the map: LLM reasoning → Mathematical reasoning

Abstract (arXiv)

Code has been shown to be effective in enhancing the mathematical reasoning abilities of large language models due to its precision and accuracy. Previous works involving continued mathematical pretraining often include code that utilizes math-related packages, which are primarily designed for fields such as engineering, machine learning, signal processing, or module testing, rather than being directly focused on mathematical reasoning. In this paper, we introduce a novel method for generating mathematical code accompanied with corresponding reasoning steps for continued pretraining. Our approach begins with the construction of a high-quality mathematical continued pretraining dataset by incorporating math-related web data, code using mathematical packages, math textbooks, and synthetic data. Next, we construct reasoning steps by extracting LaTeX expressions, the conditions needed for the expressions, and the results of the expressions from the previously collected dataset. Based on this extracted information, we generate corresponding code to accurately capture the mathematical reasoning process. Appending the generated code to each reasoning step results in data consisting of paired natural language reasoning steps and their corresponding code. Combining this data with the original dataset results in a 19.2B-token high-performing mathematical pretraining corpus, which we name MathCode-Pile. Training several popular base models with this corpus significantly improves their mathematical abilities, leading to the creation of the MathCoder2 family of models. All of our data processing and training code is open-sourced, ensuring full transparency and easy reproducibility of the entire data collection and training pipeline. The code is released at https://github.com/mathllm/MathCoder2 .

Key facts. Cited by 39 papers in the map (data through 7 Oct 2026). Placed in Mathematical reasoning, one of 17 directions in LLM reasoning. Builds on 34 of its 38 references that are in the map. First posted on arXiv 10 Oct 2024.

Builds on

34 of 38 references.

Closest ancestors · 10

Same direction, newest first

  1. 2024Step-Controlled DPO: Leveraging Stepwise Error for Enhanced Mathematical Reasoning30 Jun
  2. 2024MathGenie: Generating Synthetic Data with Question Back-translation for Enhancing Mathematical Reasoning of LLMs26 Feb
  3. 2024DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models5 Feb
  4. 2024MARIO: MAth Reasoning with code Interpreter Output -- A Reproducible Pipeline16 Jan
  5. 2023Llemma: An Open Language Model For Mathematics16 Oct
  6. 2023OpenWebMath: An Open Dataset of High-Quality Mathematical Web Text10 Oct
  7. 2023MathCoder: Seamless Code Integration in LLMs for Enhanced Mathematical Reasoning5 Oct
  8. 2023ToRA: A Tool-Integrated Reasoning Agent for Mathematical Problem Solving29 Sep
  9. 2023Scaling Relationship on Learning Mathematical Reasoning with Large Language Models3 Aug
  10. 2022Solving Quantitative Reasoning Problems with Language Models29 Jun

Other references · 24

  1. 2024The Llama 3 Herd of Modelscited by 14,192
  2. 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
  3. 2021Training Verifiers to Solve Math Word Problemscited by 9,743
  4. 2023Direct Preference Optimization: Your Language Model is Secretly a Reward Modelcited by 7,916
  5. 2020Measuring Massive Multitask Language Understandingcited by 7,768
  6. 2021Measuring Mathematical Problem Solving With the MATH Datasetcited by 5,203
  7. 2023Let's Verify Step by Stepcited by 3,598
  8. 2023Mistral 7Bcited by 3,065
  9. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  10. 2024Qwen2 Technical Reportcited by 2,076
  11. 2024Qwen2.5-Math Technical Report: Toward Mathematical Expert Model via Self-Improvementcited by 1,057
  12. 2023Math-Shepherd: Verify and Reinforce LLMs Step-by-step without Human Annotationscited by 895
12 more
  1. 2016Bag of Tricks for Efficient Text Classificationcited by 869
  2. 2023StarCoder: may the source be with you!cited by 790
  3. 2023MetaMath: Bootstrap Your Own Mathematical Questions for Large Language Modelscited by 724
  4. 2023Textbooks Are All You Needcited by 561
  5. 2023MAmmoTH: Building Math Generalist Models through Hybrid Instruction Tuningcited by 483
  6. 2024MAmmoTH2: Scaling Instructions from the Webcited by 143
  7. 2023GPT Can Solve Mathematical Problems Without a Calculatorcited by 68
  8. 2023MathPile: A Billion-Token-Scale Pretraining Corpus for Mathcited by 67
  9. 2024MAP-Neo: Highly Capable and Transparent Bilingual Large Language Model Seriescited by 67
  10. 2024Synthetic continued pretrainingcited by 56
  11. 2024ChatGLM-Math: Improving Math Problem-Solving in Large Language Models with a Self-Critique Pipelinecited by 47
  12. 2024Unearthing Large Scale Domain-Specific Knowledge from Public Corporacited by 12

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 1; 2025: 30; 2026: 8.

39 papers.

Sort:

By area:

  1. 2025Scaling up Test-Time Compute with Latent Reasoning: A Recurrent Depth Approachcited by 372
  2. 2025T2I-R1: Reinforcing Image Generation with Collaborative Semantic-level and Token-level CoTcited by 162
  3. 2024A Survey of Mathematical Reasoning in the Era of Multimodal Large Language Model: Benchmark, Method & Challengescited by 55
  4. 2025Code to Think, Think to Code: A Survey on Code-Enhanced Reasoning and Reasoning-Driven Code Intelligence in LLMscited by 47
  5. 2025MegaMath: Pushing the Limits of Open Math Corporacited by 47
  6. 2025Position: Multimodal Large Language Models Can Significantly Advance Scientific Reasoningcited by 33
  7. 2025PDE-Controller: LLMs for Autoformalization and Reasoning of PDEscited by 23
  8. 2025Nemotron-Math: Efficient Long-Context Distillation of Mathematical Reasoning from Multi-Mode Supervisioncited by 22
  9. 2025Incentivizing Agentic Reasoning in LLM Judges via Tool-Integrated Reinforcement Learningcited by 16
  10. 2025Memorization vs. Reasoning: Updating LLMs with New Knowledgecited by 12
  11. 2025Scaling Code-Assisted Chain-of-Thoughts and Instructions for Model Reasoningcited by 10
  12. 2025textttDroid: A Resource Suite for AI-Generated Code Detectioncited by 9
27 more
  1. 2025A Survey of Inductive Reasoning for Large Language Modelscited by 8
  2. 2026MergeMix: Optimizing Mid-Training Data Mixtures via Learnable Model Mergingcited by 7
  3. 2025Reasoning-OCR: Can Large Multimodal Models Solve Complex Logical Reasoning Problems from OCR Cues?cited by 6
  4. 2026Data Darwinism Part I: Unlocking the Value of Scientific Data for Pre-trainingcited by 6
  5. 2025Multi-Step Reasoning in Korean and the Emergent Miragecited by 4
  6. 2025Teaching LLMs According to Their Aptitude: Adaptive Reasoning for Mathematical Problem Solvingcited by 4
  7. 2025Alignment with Fill-In-the-Middle for Enhancing Code Generationcited by 4
  8. 2025Chain of Execution Supervision Promotes General Reasoning in Large Language Modelscited by 4
  9. 2025GPTailor: Large Language Model Pruning Through Layer Cutting and Stitchingcited by 3
  10. 2025PDE-SHARP: PDE Solver Hybrids through Analysis and Refinement Passescited by 3
  11. 2025Local Look-Ahead Guidance via Verifier-in-the-Loop for Automated Theorem Provingcited by 2
  12. 2025Code-driven Number Sequence Calculation: Enhancing the inductive Reasoning Abilities of Large Language Modelscited by 2
  13. 2025Merging Continual Pretraining Models for Domain-Specialized LLMs: A Case Study in Financecited by 2
  14. 2026Domain-Aware Scaling Laws Uncover Data Synergycited by 2
  15. 2025Code-Driven Inductive Synthesis: Enhancing Reasoning Abilities of Large Language Models with Sequencescited by 1
  16. 2025Improving LLMs' Generalized Reasoning Abilities by Graph Problemscited by 1
  17. 2025From Static to Dynamic: Adaptive Monte Carlo Search for Mathematical Process Supervisioncited by 1
  18. 2025Concept Generalization in Humans and Large Language Models: Insights from the Number Gamecited by 1
  19. 2025Evaluating the Reasoning Abilities of LLMs on Underrepresented Mathematics Competition Problemscited by 1
  20. 2025From Language to Logic: A Bi-Level Framework for Structured Reasoningcited by 0
  21. 2025Towards Reliable Multi-Agent Systems for Marketing Applications via Reflection, Memory, and Planningcited by 0
  22. 2025Parrot: A Training Pipeline Enhances Both Program CoT and Natural Language CoT for Reasoningcited by 0
  23. 2026Learning What to Predict: Downstream-Guided Task Design for Continued Pretrainingcited by 0
  24. 2026The Periodic Table of LLM Reasoning: A Structured Survey of Reasoning Paradigms, Methods, and Failure Modescited by 0
  25. 2026Everything in Moderation: Per-Domain Coverage Optima and Alignment-Resistant Domain Gaps in Multi-Domain Mid-Trainingcited by 0
  26. 2026Code Consistency Preference Optimization Verification for Language Model Alignmentcited by 0
  27. 2026MultiTalk: Scaling Full-Duplex Speech Models to Long, Multi-Party, Bilingual Conversationcited by 0

Similar, not cited

Close in wording, no citation either way

  1. 2025Advancing Mathematical Reasoning in Language Models: The Impact of Problem-Solving Data, Data Synthesis Methods, and Training Stages
  2. 2025MathFimer: Enhancing Mathematical Reasoning by Expanding Reasoning Steps through Fill-in-the-Middle Task
  3. 2024Physics of Language Models: Part 2.2, How to Learn From Mistakes on Grade-School Math Problems
  4. 2025A Survey on Large Language Models for Mathematical Reasoning
  5. 2026Mathematical Reasoning in Large Language Models: Benchmarks, Architectures, Evaluation, and Open Challenges
  6. 2025Arrows of Math Reasoning Data Synthesis for Large Language Models: Diversity, Complexity and Correctness
  7. 2024CoinMath: Harnessing the Power of Coding Instruction for Math LLMs
  8. 2022Learning Math Reasoning from Self-Sampled Correct and Partially-Correct Solutions