TL;DR
StepFun-Formalizer is a new framework that significantly improves autoformalization—the task of translating natural language math problems into formal, verifiable code (like Lean 4). By fusing large-scale formal domain knowledge with expert-guided reasoning trajectories, it achieves state-of-the-art results, outperforming even massive models like DeepSeek-R1-671B on key benchmarks.
What Problem Does This Paper Address?
Translating a math word problem into formal logic is a "double-edged" challenge. To do it well, an AI needs two distinct skills:
- Domain Knowledge: It must know the specific "vocabulary" and syntax of formal languages like Lean 4 (e.g., knowing exactly how Euler’s totient function is defined in a specific library version).
- Reasoning & Alignment: It must understand the nuances of the informal text and map them precisely to formal structures, often filling in "implicit" details that humans take for granted but code requires (like explicit type coercions).
Existing Large Language Models (LLMs) usually fail at one or the other. General-purpose models have great reasoning but lack niche formal knowledge; specialized models know the code but struggle to "read between the lines" of complex word problems.
Methods
The authors introduce ThinkingF, a pipeline designed to fuse these two abilities through a four-stage process:
- Knowledge Distillation with Selection: They used specialized models to generate 16 candidate formalizations for 256K problems. They then used majority voting and a "judge" model (DeepSeek-V3) to filter out low-quality or trivial examples, resulting in a high-quality dataset of 183K pairs.
- Reasoning Data Synthesis: To teach the model how to think about formalization, they used Claude 3.7 Sonnet to generate detailed "thought" trajectories for 5.8K expert-annotated problems. These trajectories follow a template: restating the problem, analyzing logical structures, mapping concepts to Lean 4, and anticipating technical pitfalls.
- Two-Stage Supervised Fine-Tuning (SFT): They trained their base models (DeepSeek-R1-Distill-Qwen 7B and 32B) first on the broad knowledge dataset, then on the specialized reasoning trajectories.
- Reinforcement Learning with Verifiable Reward (RLVR): Finally, they used RL to fine-tune the model further. The "reward" was determined by BEq (Bidirectional Extended Definitional Equivalence)—a method that uses a proof assistant to check if the model's generated code is semantically identical to the ground truth.
Datasets
- Training: The primary source was NuminaMath-1.5 (for distillation). They also used human-annotated data from MiniF2F, ProofNet, PutnamBench, and FormalMATH-Train.
- Evaluation: The models were tested on FormalMATH-Lite (in-domain), ProverBench (out-of-distribution), and CombiBench (combinatorial problems).
Key Insights and Ideas
- The "Off-Task" Trap: The authors found that general reasoning models often fall into "off-task" behavior—they spend their "thinking" time trying to solve the math problem instead of translating it. The ThinkingF template forces the model to focus on the formalization process itself.
- Verifiability is a Superpower: Unlike general prose, formal math code can be compiled and verified. Using the proof assistant's feedback as a reinforcement signal (RLVR) proved highly effective at "fusing" knowledge and reasoning.
- Quality Over Quantity: LLM-based filtering reduced the distilled dataset size but maintained performance, proving that removing "noisy" or oversimplified formalizations is crucial for training efficiency.
Key Results
StepFun-Formalizer sets new records across the board:
- SOTA Performance: The 32B model achieved 40.5% BEq@1 on FormalMATH-Lite and 26.7% on ProverBench, surpassing all previous specialized and general-purpose models (including OpenAI o3-pro and Claude 4-thinking).
- Efficiency: The 7B version of StepFun-Formalizer actually outperformed much larger models like DeepSeek-R1-671B and Gemini-2.5-thinking on several benchmarks, demonstrating the power of targeted data synthesis.
- Real-World Impact: In a simulation of end-to-end theorem proving, StepFun-Formalizer generated significantly more "provable" formal statements than its predecessors, particularly in Algebra and Calculus.
Limitations and Future Work
- Data Scaling: The authors noted that while the 7B model is highly optimized, the 32B model likely requires even more high-quality reasoning data to reach its full potential.
- Instruction Following: Some evaluation gaps remain because certain baseline models struggle to follow specific formatting instructions (like including headers), which can lead to an underestimation of their true capabilities.
- Future Directions: The team plans to refine their evaluation metrics and explore scaling the reasoning trajectory synthesis to even larger datasets.
Summary updated