Papers › MathCoder2: Better Math Reasoning from Continued Pretraining on Model-translated...

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

10 Oct 2024arXiv:2410.08196archive 2025-07-28

Zimu Lu, Aojun Zhou, Ke Wang, Houxing Ren, Weikang Shi, Junting Pan, Mingjie Zhan, Hongsheng Li

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 .

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2410.08196")

Code

Syntology Ran 9 of 11 code samples harvested from 1 repository linked to this paper; 2 have no recorded run. Of those that ran: 1 ran · our draft was wrong; 8 ran with no contract checked.

By repository: official repository: 11 samples from 1 repository, 9 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

mathllm/mathcoder2 officialmentioned in papermentioned on GitHub report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

11 samples harvested; 9 ran; 0 honoured the contract we drafted; 2 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · our draft was wrong
8ran
2unverified

Licence: 11 of the 11 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from mathllm/mathcoder2. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

execute_code mathllm/mathcoder2/data_processing/mathematical_code/extract_to_blocks.py official repository ran no licence file found · pointer only · b6ef8d618b02a5bb · report
is_duplicate mathllm/mathcoder2/data_processing/decontamination/exact_match_and_13-gram.py official repository ran no licence file found · pointer only · 4eb22121bb64cbea · report
is_number mathllm/mathcoder2/data_processing/mathematical_code/convert_to_text.py official repository ran no licence file found · pointer only · 3adfdbf98eb1f8fe · report
load_jsonl mathllm/mathcoder2/data_processing/mathematical_code/process.py official repository ran · our draft was wrong no licence file found · pointer only · 17081a7b73a41850 · report
load_jsonl mathllm/mathcoder2/data_processing/decontamination/exact_match_and_13-gram.py official repository ran no licence file found · pointer only · 0d0b215c235ca58d · report
load_jsonl mathllm/mathcoder2/data_processing/mathematical_code/convert_to_text.py official repository ran no licence file found · pointer only · 03083657f2dac243 · report
not_equal mathllm/mathcoder2/data_processing/mathematical_code/convert_to_text.py official repository ran no licence file found · pointer only · 85151f27b88037cb · report
not_equal mathllm/mathcoder2/data_processing/mathematical_code/execution_result_filter.py official repository ran no licence file found · pointer only · fc79a9a32d1b7125 · report
to_blocks mathllm/mathcoder2/data_processing/mathematical_code/extract_to_blocks.py official repository ran fingerprinted no licence file found · pointer only · bdcc0fdf687b26e4 · report
add_execution_result mathllm/mathcoder2/data_processing/mathematical_code/execute_code.py official repository unverified no licence file found · pointer only · 7499e0bcb2627ca6 · report
process mathllm/mathcoder2/data_processing/mathematical_code/process.py official repository unverified no licence file found · pointer only · abf0c42ae4c8f624 · report

Tasks

MathMathematical Reasoning

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

BASE

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections