atlas

Research map / Large language models / Agents, code and math

MathCoder: Seamless Code Integration in LLMs for Enhanced Mathematical Reasoning

ICLR 2024 · Large language models › Agents, code and math · approach: Code generation benchmarks · 4 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.

Fine-tunes Llama-2 and CodeLlama on MathCodeInstruct, an 80k dataset of interleaved natural-language, code, and execution-result solutions (plus problem-interpolation data), with loss masked on execution outputs, yielding MathCoder models that set open-source SOTA on GSM8K and MATH.

Problem

Open-source LLMs lag closed-source models on math reasoning and cannot replicate the GPT-4 Code Interpreter style of interleaving reasoning, code generation, and execution feedback.

Approach

Generate GPT-4 Code Interpreter-style LCE (natural language, code, execution result) solutions for GSM8K and MATH, augment data with a problem-interpolation prompt that creates intermediate-difficulty problems solved by self-distillation, then SFT with special block tokens, loss excluding execution results, and real code execution during inference in a Jupyter kernel.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Add problem-interpolation examples to GSM8K+MATH training data (ablation)CodeLlama-34B MathCoder · GSM8Kaccuracy: 77.3 -> 81.7; +4.4Helped
Add problem-interpolation examples to GSM8K+MATH training data (ablation)CodeLlama-34B MathCoder · MATHaccuracy: 44.0 -> 45.2; +1.2Helped
Add problem-interpolation examples to GSM8K+MATH training data (ablation)CodeLlama-34B MathCoder · SVAMPaccuracy: 78.6 -> 82.5; +3.9Helped
Add problem-interpolation examples to GSM8K+MATH training data (ablation)CodeLlama-34B MathCoder · Mathematicsaccuracy: 71.6 -> 75.9; +4.3Helped
Add problem-interpolation examples to GSM8K+MATH training data (ablation)CodeLlama-34B MathCoder · SimulEqaccuracy: 59.3 -> 65.8; +6.4Helped
Use actual code execution rather than model-predicted execution results at inference (ablation)CodeLlama-34B MathCoder · GSM8Kaccuracy: 54.1 -> 79.9; +25.8Helped
Use actual code execution rather than model-predicted execution results at inference (ablation)CodeLlama-34B MathCoder · MATHaccuracy: 16.9 -> 45.9; +29.0Helped
Use actual code execution rather than model-predicted execution results at inference (ablation)CodeLlama-34B MathCoder · SVAMPaccuracy: 69.6 -> 81.9; +12.3Helped
Use actual code execution rather than model-predicted execution results at inference (ablation)CodeLlama-34B MathCoder · Mathematicsaccuracy: 20.6 -> 74.2; +53.6Helped
Use actual code execution rather than model-predicted execution results at inference (ablation)CodeLlama-34B MathCoder · SimulEqaccuracy: 14.2 -> 63.6; +49.4Helped
Exclude execution-result tokens from the training loss (ablation)CodeLlama-34B MathCoder with actual execution · GSM8Kaccuracy: 79.9 -> 81.7; +1.8Helped
Exclude execution-result tokens from the training loss (ablation)CodeLlama-34B MathCoder with actual execution · MATHaccuracy: 45.9 -> 45.2; -0.7Hurt

Surprising findings

Limitations

Experimental setup

Datasets: GSM8K MATH SVAMP Mathematics SimulEq

Benchmarks: GSM8K MATH SVAMP Mathematics SimulEq

Metrics: accuracy average accuracy

Baselines: ChatGPT-3.5 GPT-4 GPT-4 Code Interpreter PaLM-2 WizardMath Llama-1 RFT Galactica

Builds on: Program-aided language models (PAL) Chain-of-thought prompting Alpaca CodeLlama Llama-2

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