Skip to main content
QUICK REVIEW

[论文解读] MathCoder: Seamless Code Integration in LLMs for Enhanced Mathematical Reasoning

Ke Wang, Houxing Ren|arXiv (Cornell University)|Oct 5, 2023
Computational Physics and Python Applications被引用 4
一句话总结

MathCoder 通过在一种新型数据集 MathCodeInstruct 上微调,提出了一套框架以增强开源大语言模型的数学推理能力,该数据集将自然语言推理、代码生成和执行结果交织在一起。该方法在 GSM8K(83.9%)和 MATH(45.2%)上取得了最先进性能,超越了其他开源模型,甚至在竞赛级 MATH 基准测试中超过 GPT-4。

ABSTRACT

The recently released GPT-4 Code Interpreter has demonstrated remarkable proficiency in solving challenging math problems, primarily attributed to its ability to seamlessly reason with natural language, generate code, execute code, and continue reasoning based on the execution output. In this paper, we present a method to fine-tune open-source language models, enabling them to use code for modeling and deriving math equations and, consequently, enhancing their mathematical reasoning abilities. We propose a method of generating novel and high-quality datasets with math problems and their code-based solutions, referred to as MathCodeInstruct. Each solution interleaves natural language, code, and execution results. We also introduce a customized supervised fine-tuning and inference approach. This approach yields the MathCoder models, a family of models capable of generating code-based solutions for solving challenging math problems. Impressively, the MathCoder models achieve state-of-the-art scores among open-source LLMs on the MATH (45.2%) and GSM8K (83.9%) datasets, substantially outperforming other open-source alternatives. Notably, the MathCoder model not only surpasses ChatGPT-3.5 and PaLM-2 on GSM8K and MATH but also outperforms GPT-4 on the competition-level MATH dataset. The dataset and models will be released at https://github.com/mathllm/MathCoder.

研究动机与目标

  • 弥合开源与闭源大语言模型在数学推理能力上的性能差距。
  • 使开源模型能够模拟 GPT-4 Code Interpreter 将推理、代码与执行结果交织的能力。
  • 构建一个高质量、遵循指令的多模态数据集,结合自然语言、代码与执行输出,用于数学问题求解。
  • 设计一种定制化的监督微调与推理流水线,支持推理过程中无缝集成代码。
  • 仅使用开源模型,在标准数学基准测试上实现最先进性能。

提出的方法

  • 通过为 80,000 个数学问题生成类似 GPT-4 Code Interpreter 的解决方案,构建 MathCodeInstruct 数据集,包含自然语言、代码与执行结果。
  • 采用两阶段数据收集流程:第一阶段,为现有的 GSM8K 和 MATH 问题生成解决方案;第二阶段,应用问题插值技术生成中等难度的问题。
  • 采用专用的标记化方案,使用特殊标记(<$|$ text $|$>、<$|$ code $|$>、<$|$ execution $|$>)对模型输入进行结构化,以支持交错推理。
  • 使用 MathCodeInstruct 数据集对 Llama-2 基础模型进行监督微调,以支持基于代码的推理。
  • 设计一种训练与推理流水线,模拟 GPT-4 Code Interpreter 的行为,使模型能够生成、执行并基于代码输出进行推理。
  • 应用自蒸馏技术,进一步提升模型在增强数据集上的性能。

实验结果

研究问题

  • RQ1通过集成代码的指令微调,开源大语言模型是否能在数学推理方面达到与 GPT-4 Code Interpreter 相当的性能?
  • RQ2一种将自然语言、代码与执行结果交织的数据集,在提升数学推理能力方面是否有效?
  • RQ3问题插值是否能有效生成中等难度的数学问题,以提升模型的泛化能力?
  • RQ4一种支持代码执行与推理的定制化微调流水线,是否能提升模型在高难度数学基准上的表现?
  • RQ5开源模型是否能在竞赛级数学问题上超越现有开源模型,甚至超越 GPT-4?

主要发现

  • MathCoder 在 GSM8K 基准测试中取得了 83.9% 的最先进成绩,显著优于其他开源大语言模型。
  • 在 MATH 基准测试中,MathCoder 达到了 45.2% 的准确率,超越了所有先前的开源模型,甚至在竞赛级子集上超过 GPT-4。
  • 该模型在 GSM8K 和 MATH 上的表现均优于 ChatGPT-3.5 和 PaLM-2,展现出强大的泛化与推理能力。
  • MathCodeInstruct 数据集通过其文本、代码与执行结果的交织结构,提供了比纯自然语言或仅代码解决方案更有效的监督。
  • 自蒸馏与问题插值显著提升了模型的泛化能力,尤其是在更难的问题上。
  • 定制化的微调与推理流水线成功使开源模型能够模拟 GPT-4 Code Interpreter 的“基于代码的推理”工作流。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。