Everything K-culture — comebacks to K-beauty, straight to your inboxGet it in your inbox

METAL MEDIA

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

arXiv:2608.142212026-08-14

Retrieving the right math-library knowledge and letting a compiler point out mistakes lets a small 8B model beat 32B specialized systems at turning math text into verified code

Autoformalization, converting natural-language math statements into machine-checkable Lean 4 code, is not just translation but requires correctly mapping concepts onto Mathlib's huge library of definitions and types. The authors built MathForm, a pipeline that retrieves relevant Mathlib knowledge before generation and then iteratively fixes candidates using compiler errors and semantic-consistency feedback, producing a verified dataset of about 367K examples called FormalVerse. A model trained on this data, MathForm-8B, reaches average pass rates of 88.06% (syntax) and 72.37% (semantic consistency) across six benchmarks, beating several 32B specialized autoformalizers.

METAL MEDIA explanatory visual

Retrieving the right math-library knowledge and letting a compiler point out mistakes lets a small 8B model beat 32B specialized systems at turning math text into verified code

  1. 01Prior methods leaned on a model's memorized knowledge, causing it to cite nonexistent lemmas or violate library conventions, while typical data pipelines just filtered large batches of single-pass outputs without explaining failures
  2. 02MathForm adds a retrieval planner that pulls relevant Mathlib definitions before generation, then runs up to three rounds of refinement guided by compiler diagnostics and a semantic-consistency judge (QwQ-32B during construction, gpt-oss-120b for final evaluation)
  3. 03The resulting FormalVerse dataset (about 367K verified examples) was used to train Qwen3-8B via supervised fine-tuning followed by reinforcement learning (DAPO) to produce MathForm-8B
  4. 04On the hardest FATE-H and FATE-X benchmarks, MathForm-8B reached semantic-consistency pass rates of 63% and 37%, beating the strongest specialized baselines by 10 and 12 percentage points, with gains growing on more abstract algebra topics
  5. 05Under a controlled 100K-example comparison, models trained on FormalVerse beat those trained on other public Lean 4 datasets by up to 18.83 percentage points in semantic-consistency pass rate
An explanatory diagram made by METAL MEDIA, not a figure supplied by the paper's authors.

What they did

  1. Prior methods leaned on a model's memorized knowledge, causing it to cite nonexistent lemmas or violate library conventions, while typical data pipelines just filtered large batches of single-pass outputs without explaining failures
  2. MathForm adds a retrieval planner that pulls relevant Mathlib definitions before generation, then runs up to three rounds of refinement guided by compiler diagnostics and a semantic-consistency judge (QwQ-32B during construction, gpt-oss-120b for final evaluation)
  3. The resulting FormalVerse dataset (about 367K verified examples) was used to train Qwen3-8B via supervised fine-tuning followed by reinforcement learning (DAPO) to produce MathForm-8B
  4. On the hardest FATE-H and FATE-X benchmarks, MathForm-8B reached semantic-consistency pass rates of 63% and 37%, beating the strongest specialized baselines by 10 and 12 percentage points, with gains growing on more abstract algebra topics
  5. Under a controlled 100K-example comparison, models trained on FormalVerse beat those trained on other public Lean 4 datasets by up to 18.83 percentage points in semantic-consistency pass rate
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

Why it matters

Training AI to prove math theorems requires huge amounts of verified formal-language data that humans cannot easily produce by hand, and this work shows a more accurate automated way to generate it. It also demonstrates that a small model paired with good data and a verification pipeline can outperform much larger specialized systems, which matters for cost-efficient AI development.

Terms in this paper

  • Autoformalization · Automatically translating natural-language math statements into a machine-checkable formal language like Lean 4
  • Lean 4 / Mathlib · A proof assistant language for machine-verifiable math (Lean) and its large library of formal definitions and theorems (Mathlib)
  • Syntax Check (SC) / Consistency Check (CC) · SC checks whether generated code compiles correctly; CC checks whether it truly preserves the meaning of the original statement
  • Pass@8 · A metric measuring how often a model succeeds within 8 attempts per problem
  • DAPO / Reinforcement Learning (RL) · A training method that adjusts a model using reward signals comparing multiple generated candidates to favor better ones

Original abstract (English)

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.

Authors · Lushi Pu

Read on arXiv

Latest papers

All papers →

Latest from METAL MEDIA

Figures: Lushi Pu et al., arXiv:2608.14221, CC BY 4.0