用数学推理代码增强大模型,显著提升数学能力。
MathCoder2: Better Math Reasoning from Continued Pretraining on Model-translated Mathematical Code
- 通过自动生成带推理步骤的数学代码构建高质量数据集。
- 训练后模型在数学基准测试中平均提升19.2%准确率。
- 适合需要强数学推理能力的研究者和开发者使用。
代码因其精确性被证明能有效提升大语言模型的数学推理能力。以往的数学持续预训练多使用工程、机器学习等领域相关的代码,而非聚焦于数学推理本身。本文提出一种新方法,生成带有相应推理步骤的数学代码用于持续预训练。首先,通过整合数学网页数据、使用数学包的代码、数学教材及合成数据,构建高质量数学持续预训练数据集。接着,从数据集中提取LaTeX表达式、其成立条件及计算结果,并据此生成准确反映数学推理过程的代码。将生成代码与对应推理步骤配对,形成自然语言推理与代码的成对数据。结合原始数据,构建出总计19.2B token的高性能数学预训练语料库,命名为MathCode-Pile。使用该语料库训练多个主流基础模型,显著提升其数学能力,由此诞生MathCoder2系列模型。所有数据处理与训练代码已开源,确保全流程透明可复现,项目地址为https://github.com/mathllm/MathCoder2。
原文摘要 · Abstract (English)
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 .
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。