Ke WangHouxing RenAojun ZhouZimu LuSichun LuoWeikang ShiRenrui ZhangLinqi SongMingjie ZhanHongsheng Li

摘要
最近发布的 GPT-4 代码解释器在解决复杂数学问题方面展现出卓越的能力,这主要归功于其能够无缝结合自然语言推理、代码生成、代码执行以及基于执行结果持续进行推理的能力。在本文中,我们提出了一种微调开源语言模型的方法,使其能够利用代码进行数学建模与方程推导,从而显著提升其数学推理能力。为此,我们构建了一种新颖且高质量的数据集生成方法,该方法涵盖数学问题及其基于代码的解决方案,命名为 MathCodeInstruct。该数据集中的每一条解决方案均以自然语言、代码与执行结果交替穿插的形式呈现,充分体现了“推理—编码—执行—反馈”的闭环过程。此外,我们还设计了一种定制化的监督微调与推理框架。基于此框架,我们训练出 MathCoder 系列模型,该系列模型具备生成基于代码的数学问题求解方案的能力。令人瞩目的是,MathCoder 模型在 MATH 数据集(45.2%)和 GSM8K 数据集(83.9%)上的表现达到当前开源大语言模型的最先进水平,显著优于其他开源模型。尤为突出的是,MathCoder 不仅在 GSM8K 和 MATH 数据集上超越了 ChatGPT-3.5 与 PaLM-2,更在竞赛级别的 MATH 数据集上实现了对 GPT-4 的超越。相关数据集与模型将开源发布于:https://github.com/mathllm/MathCoder。
代码仓库
mathllm/mathcoder
官方
GitHub 中提及
基准测试
| 基准 | 方法 | 指标 |
|---|---|---|
| arithmetic-reasoning-on-gsm8k | MathCoder-CL-13B | Accuracy: 74.1 Parameters (Billion): 7 |
| arithmetic-reasoning-on-gsm8k | MathCoder-CL-7B | Accuracy: 67.8 Parameters (Billion): 7 |
| arithmetic-reasoning-on-gsm8k | MathCoder-L-13B | Accuracy: 72.6 Parameters (Billion): 13 |
| arithmetic-reasoning-on-gsm8k | MathCoder-L-70B | Accuracy: 83.9 Parameters (Billion): 70 |
| arithmetic-reasoning-on-gsm8k | MathCoder-CL-34B | Accuracy: 81.7 Parameters (Billion): 34 |
| arithmetic-reasoning-on-gsm8k | MathCoder-L-7B | Accuracy: 64.2 Parameters (Billion): 7 |
| math-word-problem-solving-on-math | MathCoder-CL-7B | Accuracy: 30.2 Parameters (Billions): 7 |
| math-word-problem-solving-on-math | MathCoder-CL-34B | Accuracy: 45.2 Parameters (Billions): 34 |
| math-word-problem-solving-on-math | MathCoder-CL-13B | Accuracy: 35.9 Parameters (Billions): 13 |
| math-word-problem-solving-on-math | MathCoder-L-34B | Accuracy: 45.1 Parameters (Billions): 34 |
| math-word-problem-solving-on-math | MathCoder-L-7B | Accuracy: 23.3 Parameters (Billions): 7 |
| math-word-problem-solving-on-math | MathCoder-L-13B | Accuracy: 29.9 Parameters (Billions): 13 |
| math-word-problem-solving-on-svamp | MathCoder-L-70B | Execution Accuracy: 84.9 |