K-文化的一切——从回归到 K-美妆,发送到您的邮箱订阅邮件

METAL MEDIA

MathForm: Scaling Mathematical Autoformalization with Knowledge Retrieval and Verification-Guided Refinement

arXiv:2608.142212026-08-14

先检索数学库知识、再让编译器和语义判定反复纠错,能让一个8B小模型在把数学题转成可验证代码这件事上打败32B专用模型

自动形式化是把自然语言写的数学命题转换成Lean 4这类机器可验证代码的任务,但它不只是翻译,还需要把数学概念准确映射到Mathlib这个庞大数学库的定义和类型体系中。作者提出MathForm框架,在生成前先从Mathlib检索相关知识,生成后再用编译器诊断和语义一致性反馈进行多轮修正,由此构建了约36.7万条经过验证的数据集FormalVerse。用该数据训练的MathForm-8B在六个基准测试上平均语法通过率达88.06%,语义一致通过率达72.37%,超过多个32B级专用自动形式化模型。

METAL MEDIA 解读图

先检索数学库知识、再让编译器和语义判定反复纠错,能让一个8B小模型在把数学题转成可验证代码这件事上打败32B专用模型

  1. 01以往方法过度依赖模型记忆的知识,容易引用Mathlib中不存在的定理或违反库的命名习惯,而常见的数据构建流程只是对大批量单次生成结果做事后筛选,无法指出错误出在哪里
  2. 02MathForm在生成前用检索规划器从Mathlib取回相关定义和已有形式化案例,生成后经过最多三轮修正,依据编译诊断和语义一致性判定(数据构建阶段用QwQ-32B作裁判,最终评测用gpt-oss-120b)不断改进候选结果
  3. 03基于约36.7万条验证数据FormalVerse,先对Qwen3-8B做监督微调,再用强化学习方法DAPO进一步训练,得到MathForm-8B
  4. 04在最具挑战性的FATE-H和FATE-X测试集上,MathForm-8B的语义一致通过率分别达到63%和37%,比最强专用基线高出10和12个百分点,且在抽象代数等更依赖库知识的领域优势更明显
  5. 05在相同10万条数据规模的对照实验中,用FormalVerse训练的模型比用其他公开Lean 4数据集训练的模型语义一致通过率最高高出18.83个百分点
这是 METAL MEDIA 制作的解读图,并非论文作者提供的原图。

他们做了什么

  1. 以往方法过度依赖模型记忆的知识,容易引用Mathlib中不存在的定理或违反库的命名习惯,而常见的数据构建流程只是对大批量单次生成结果做事后筛选,无法指出错误出在哪里
  2. MathForm在生成前用检索规划器从Mathlib取回相关定义和已有形式化案例,生成后经过最多三轮修正,依据编译诊断和语义一致性判定(数据构建阶段用QwQ-32B作裁判,最终评测用gpt-oss-120b)不断改进候选结果
  3. 基于约36.7万条验证数据FormalVerse,先对Qwen3-8B做监督微调,再用强化学习方法DAPO进一步训练,得到MathForm-8B
  4. 在最具挑战性的FATE-H和FATE-X测试集上,MathForm-8B的语义一致通过率分别达到63%和37%,比最强专用基线高出10和12个百分点,且在抽象代数等更依赖库知识的领域优势更明显
  5. 在相同10万条数据规模的对照实验中,用FormalVerse训练的模型比用其他公开Lean 4数据集训练的模型语义一致通过率最高高出18.83个百分点
Figure 1: Macro-average Pass@8 (%) across six benchmarks among specialized autoformalizers. MathForm-8B achieves the strongest overall performance within this category despite its smaller model size.
Figure 1: Macro-average Pass@8 (%) across six benchmarks among specialized autoformalizers. MathForm-8B achieves the strongest overall performance within this category despite its smaller model size.
Table 1: Pass@8 pass rates (%) under Syntax Check (SC) and Consistency Check (CC) for specialized autoformalizers on six benchmarks. AVG is the equally weighted macro-average across all six benchmarks. For each column, the best result is shown in bold and the second best is underlined.
AVGFormalMATHProverBenchCombiBenchFATE-MFATE-HFATE-X
ModelSCCCSCCCSCCCSCCCSCCCSCCCSCCC
Specialized Autoformalizers
Herald Translator-7B64.1227.6395.2947.7678.7437.3677.005.0070.6754.6742.0015.0021.006.00
Kimina-Autoformalizer-7B73.2034.3799.2976.2496.5556.3295.0016.0077.3344.6743.008.0028.005.00
Mathesis-HPO-7B76.2034.9699.0679.2997.1359.7796.0015.0084.0048.6750.004.0031.003.00
StepFun-Formalizer-7B58.1239.5597.4181.4189.6659.2079.0028.0060.6752.6717.0012.005.004.00
StepFun-Formalizer-32B63.6544.4799.0685.8892.5364.9486.0032.0071.3360.0023.0017.0010.007.00
Goedel-Formalizer-V2-8B78.2460.0898.8294.1298.2889.6689.0042.0087.3382.6762.0044.0034.008.00
Goedel-Formalizer-V2-32B78.2863.7499.0694.5998.2892.5391.0049.0089.3385.3363.0048.0029.0013.00
ReForm-8B81.7666.2199.0694.1298.8590.8086.0047.0094.6791.3367.0053.0045.0021.00
ReForm-32B81.6168.4199.0695.5398.2894.2593.0055.0091.3388.6769.0052.0039.0025.00
Ours
MathForm-8B-SFT84.3866.5399.2991.06100.0090.8083.0043.0098.0091.3380.0058.0046.0025.00
MathForm-8B88.0672.37100.0095.06100.0094.8393.0047.0099.3397.3382.0063.0054.0037.00
Figure 2: Overview of the MathForm data construction and training pipeline. The system combines Mathlib knowledge retrieval, compilation and semantic verification, and iterative refinement to generate reliable formal data, followed by trajectory reconstruction and training of MathForm-8B.
Figure 2: Overview of the MathForm data construction and training pipeline. The system combines Mathlib knowledge retrieval, compilation and semantic verification, and iterative refinement to generate reliable formal data, followed by trajectory reconstruction and training of MathForm-8B.
Table 2: Ablation results for SC and CC pass rates (%) of the refinement pipeline with two generators on the FATE series. Single denotes single-pass generation; BoN denotes Best-of-N; Feedback denotes feedback-only iteration; and Retrieval denotes retrieval-only single-pass generation. AVG is the equally weighted average over FATE-M, FATE-H, and FATE-X.
AVGFATE-MFATE-HFATE-X
MethodSCCCSCCCSCCCSCCC
gpt-oss-120b
Single27.3326.4352.0051.3021.0019.009.009.00
BoN42.6741.1070.0069.3040.0037.0018.0017.00
Feedback42.5740.7768.7067.3041.0038.0018.0017.00
Retrieval32.2329.0056.7052.0027.0026.0013.009.00
MathForm49.6748.0076.0074.0046.0044.0027.0026.00
Qwen3-235B-A22B-Thinking-2507
Single7.437.4313.3013.305.005.004.004.00
BoN18.7718.7733.3033.3014.0014.009.009.00
Feedback28.7728.7751.3051.3022.0022.0013.0013.00
Retrieval9.908.5716.7016.708.006.005.003.00
MathForm37.5736.2360.7058.7032.0031.0020.0019.00
Figure 3: Distribution of natural-language problem sources in FormalVerse.
Figure 3: Distribution of natural-language problem sources in FormalVerse.
Table 3: Pass@8 SC and CC pass rates (%) of models trained on different datasets across six benchmarks. All models are initialized from Qwen3-8B and trained on 100K examples under the same trajectory reconstruction and training configuration. AVG is the equally weighted macro-average across all six benchmarks. The best result in each column is shown in bold and the second best is underlined.
AVGFormalMATHProverBenchCombiBenchFATE-MFATE-HFATE-X
Training DatasetSCCCSCCCSCCCSCCCSCCCSCCCSCCC
NuminaMath-LEAN66.2441.4999.5385.1896.5572.4187.0025.0069.3349.3335.0016.0010.001.00
FineLeanCorpus78.2546.53100.0084.4798.8574.7196.0029.0090.6768.0053.0017.0031.006.00
FormalVerse77.1760.3298.8290.5998.8589.6678.0036.0095.3384.6762.0046.0030.0015.00
Figure 4: Numbers of natural-language-to-formal-language pairs accepted in successive refinement rounds. Later rounds contribute an additional 31.0% of all retained pairs.
Figure 4: Numbers of natural-language-to-formal-language pairs accepted in successive refinement rounds. Later rounds contribute an additional 31.0% of all retained pairs.
Table 4: Judge-model reliability on the human-annotated semantic-consistency test set (Mean@3).
Judge ModelAccuracyPrecisionRecallF1
gpt-oss-120b0.89170.87550.91330.8940
QwQ-32B0.85670.83670.88670.8609
gpt-oss-20b0.85000.81420.90670.8579
Figure 5: Training dynamics during reinforcement learning. The left panel shows the training reward and its exponential moving average (EMA), while the right panel reports the Mean@3 pass rate on FATE-H over the course of training.
Figure 5: Training dynamics during reinforcement learning. The left panel shows the training reward and its exponential moving average (EMA), while the right panel reports the Mean@3 pass rate on FATE-H over the course of training.
Table 5: Supervised fine-tuning hyperparameters.
HyperparameterValue
Maximum sequence length16,384
Global batch size128
Learning rate2.0×10−5
Epochs3
LR schedulerCosine
Warmup ratio0.1
Precisionbf16
Figure 6: Category distribution of the natural-language mathematical problems in FormalVerse.
Figure 6: Category distribution of the natural-language mathematical problems in FormalVerse.
Table 7: Pass@8 SC and CC pass rates (%) of general-purpose LLMs and MathForm-8B across six benchmarks. AVG is the equally weighted macro-average across all six benchmarks. The best result in each column is shown in bold and the second best is underlined.
AVGFormalMATHProverBenchCombiBenchFATE-MFATE-HFATE-X
ModelSCCCSCCCSCCCSCCCSCCCSCCCSCCC
General-Purpose LLMs
DeepSeek-V4-Pro78.3476.5497.8896.2494.8393.6885.0081.0087.3387.3370.0068.0035.0033.00
Qwen3.7-Plus86.3383.3899.2998.59100.0097.7092.0087.0094.6792.0078.0077.0054.0048.00
Qwen3-235B-A22B-Thinking-250758.9455.3791.2988.2481.0375.2959.0050.0071.3370.6732.0030.0019.0018.00
Qwen3-32B43.0736.5580.9472.9461.4950.0043.0027.0046.0043.3320.0019.007.007.00
DeepSeek-R1-0528-Qwen3-8B47.2837.6572.2461.1852.3040.2336.0015.0036.0030.004.004.004.001.00
Qwen3-8B27.2517.0661.8842.1237.9327.5929.007.0026.6722.674.003.004.000.00
Ours
MathForm-8B88.0672.37100.0095.06100.0094.8393.0047.0099.3397.3382.0063.0054.0037.00
Table 8: Human-evaluation results (%) on FATE-M and FATE-H, based on one randomly sampled candidate per problem. The best result in each column is shown in bold.
FATE-MFATE-H
ModelSCCCSCCC
StepFun-Formalizer-32B42.6736.0016.0012.00
Goedel-Formalizer-V2-32B75.3368.0038.0027.00
ReForm-32B78.6774.0050.0041.00
MathForm-8B86.6776.6754.0042.00

为什么重要

训练能证明数学定理的AI系统需要大量人工难以生产的、经过验证的形式化数据,这项工作展示了一种更准确的自动生产方式。同时它证明了搭配优质数据和验证流程的小模型可以超越大得多的专用系统,这对追求性价比的AI开发很有参考价值。

本文术语

  • 自动形式化(Autoformalization) · 把自然语言写的数学命题自动转换成Lean等机器可验证形式语言的过程
  • Lean 4 / Mathlib · 一种用于机器验证数学证明的证明助理语言(Lean)及其内置的大型定义与定理库(Mathlib)
  • 语法检查(SC)/一致性检查(CC) · SC检查生成代码是否能正确编译,CC检查生成代码是否真正保留了原始命题的含义
  • Pass@8 · 衡量模型在每题8次尝试中成功比例的评测指标
  • DAPO/强化学习(RL) · 一种通过比较模型生成的多个候选结果并给予奖励信号来调整模型、使其偏好更优结果的训练方法

论文原文摘要(英文)

Autoformalization is commonly framed as translating natural-language mathematical statements into machine-verifiable formal languages such as Lean 4. However, faithful formalization requires more than translation. Models must map mathematical concepts to the complex hierarchy of types and definitions in formal libraries such as Mathlib, while ensuring that generated statements preserve the meaning of the source propositions. Existing approaches struggle because they rely heavily on the model's parametric memory for library-specific knowledge, while common data construction pipelines often resort to filtering single-pass outputs and lack mechanisms for feedback-driven revision. To address these challenges, we introduce MathForm, an autoformalization framework for constructing verified training data through Mathlib knowledge retrieval and verification-guided iterative refinement. Before generation, a retrieval planner gathers relevant definitions and existing formalizations from Mathlib to guide the formalization generator. Generated statements are then revised using compiler diagnostics and semantic-consistency feedback. Using this framework, we construct FormalVerse, a Lean 4 dataset containing approximately 367K verified examples across diverse mathematical domains and sources. We then train MathForm-8B through supervised fine-tuning followed by reinforcement learning. Across six benchmarks, MathForm-8B achieves average Pass@8 rates of 88.06% under Syntax Check (SC) and 72.37% under Consistency Check (CC), outperforming multiple specialized 32B autoformalizers. On the challenging FATE-H and FATE-X subsets, it attains CC pass rates of 63% and 37%, exceeding the strongest specialized baselines in both cases.

作者 · Lushi Pu

在 arXiv 阅读

最新论文

全部论文 →

METAL MEDIA 最新报道

图片来源: Lushi Pu et al., arXiv:2608.14221, CC BY 4.0