atlas

Research map / Large language models / Reasoning and chain of thought

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

ICLR 2025 · Large language models › Reasoning and chain of thought · approach: Search and self-correction in reasoning · 0 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Builds a 19.2B-token math pretraining corpus (MathCode-Pile) by pairing LLM-extracted LaTeX reasoning steps with execution-verified Python code, and continues pretraining four 7-8B base models to produce MathCoder2.

Problem

Existing continued math pretraining corpora include code that uses math-related packages but lacks natural-language reasoning context and is mostly designed for non-math fields, limiting its value for mathematical reasoning.

Approach

Extract LaTeX expressions with their conditions and results from math web/textbook text using an instruction-tuned LLM, translate each reasoning step into Python, execute and keep only snippets whose output matches the expected result, and concatenate code with the reasoning step for pretraining.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
add model-translated mathematical code paired with reasoning steps to continued pretraining (ablation)Llama-3-8B · MATH / GSM8K / SAT / OCW / MMLU-MATHaccuracy: +3.7 MATH, +4.1 GSM8K, +12.5 SAT, +5.1 OCW, +1.3 MMLU-MATHHelped
concatenated reasoning step + code data vs reasoning-step-only or code-only (ablation)DeepSeekCoder-1.3B · MATHaccuracy: 17.8 vs 16.7 (reasoning-step-only) and 14.6 (trans-code-only)Helped
replace code data with rewritten texts from the same LLM (no-code prompt) (ablation)DeepSeekCoder-1.3B · MATHaccuracy: 15.7 vs 17.8 for full methodHurt
continued pretraining on MathCode-Pile instead of base modelLlama-3-8B, DeepSeekMath-7B, Mistral-7B, Code-Llama-7B · MATH (4-shot)accuracy: +17.0 (Llama-3), +2.4 (DeepSeekMath), +23.6 (Mistral), +22.1 (Code-Llama)Helped
continued pretraining on MathCode-Pile instead of base modelLlama-3-8B, DeepSeekMath-7B, Mistral-7B, Code-Llama-7B · GSM8K (4-shot)accuracy: +15.1, +4.6, +16.0, +37.7Helped
add translated code paired with reasoning steps before NuminaMath-TIR SFT (ablation)Llama-3-8B (MathCoder2 vs Basic) · MATH after SFTaccuracy: 65.1 vs 62.9Helped
filtering irrelevant documents from OpenWebMath and CC-En-math (ablation)DeepSeekCoder-1.3B · MATH / GSM8Kaccuracy: filtered-OpenWebMath 9.0 MATH vs OpenWebMath 9.4; GSM8K 11.4 vs 11.2No clear effect
adding synthetic data, textbooks, or math code to filtered-OpenWebMath (ablation)DeepSeekCoder-1.3B · MATHaccuracy: synthetic 10.8, textbooks 9.4, code 9.4 vs filtered-OpenWebMath 9.0Mixed

Surprising findings

Limitations

Experimental setup

Datasets: OpenWebMath Common Crawl (Matrix) Education-College-Students Maths-College StarCoderData Mathematical textbooks (Nougat-converted PDFs) NuminaMath-CoT NuminaMath-TIR

Benchmarks: GSM8K MATH SAT-Math OCW MMLU-Math Olympiad Bench SVAMP

Metrics: accuracy (greedy decoding)

Baselines: Qwen2-Math Qwen2.5-Math InternLM2-Math-Base InternLM2.5 DeepSeekMath Llemma Mistral Llama-3 Code-Llama OpenWebMath Proof-Pile-2 MathPile

Builds on: OpenWebMath DeepSeekMath corpus fastText Llemma MAmmoTH

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy