InternLM-Math: Open Math Large Language Models Toward Verifiable Reasoning

Huaiyuan Ying, Shuo Zhang, Linyang Li, Zhejian Zhou, Yunfan Shao, Zhaoye Fei, Yichuan Ma, Jiawei Hong, Kuikun Liu, Ziyi Wang, Yudong Wang, Zijian Wu, Shuaibin Li, Fengzhe Zhou, Hongwei Liu, Songyang Zhang, Wenwei Zhang, Hang Yan, Xipeng Qiu, Jiayu Wang, Kai Chen, Dahua LinarXiv 2024 · DOI

Introduction

InternLM-Math is a new suite of open-source large language models (LLMs) specifically engineered for high-level mathematical reasoning. By unifying chain-of-thought reasoning, reward modeling, and formal mathematical languages like LEAN, these models don't just solve problems—they move toward verifiable reasoning, achieving state-of-the-art performance among open-source models on benchmarks like MATH and MiniF2F.

The Challenge of Mathematical Reasoning

While LLMs have shown impressive capabilities in general conversation, mathematical reasoning remains a frontier of failure. Standard models often suffer from two major issues:

  1. Calculation Hallucination: They skip steps or produce "magic" numbers that are incorrect.
  2. Lack of Verifiability: A model might reach the correct answer through flawed logic, or a wrong answer through sound logic, with no mechanism to detect its own mistakes.

The authors aim to move beyond simple "answer-guessing" toward a model that acts as a versatile math assistant: a solver, a verifier, a prover (writing formal code to prove a theorem), and an augmenter.

Methodology: RICO and Formal Reasoning

InternLM-Math is built on the InternLM2 base using a multi-stage approach. A core innovation is RICO (Reasoning Interleaved with COding). Unlike standard "Program-of-Thought" approaches where a model writes one block of code at the end, RICO allows the model to reason, write a snippet of Python, observe the execution result, and then continue reasoning. This "inner monologue" with a compiler significantly reduces calculation errors.

Comparison of standard Chain-of-Thought (CoT) and Reasoning Interleaved with COding (RICO). RICO allows the model to verify intermediate steps using a Python interpreter.

Beyond RICO, the model uses:

  • Unified Seq2Seq Format: A single format supervises the model on Chain-of-Thought (COT), reward modeling, and formal reasoning.
  • Formal Reasoning with LEAN: The model translates natural language problems into LEAN, a formal proof language, allowing for mathematical certainty through computer verification.

Data and Training

The training pipeline involved a massive mix of sources:

  • Pre-training: 31.2 billion unique tokens including the "Knowledge Pile" (CC), Open-web-math, and Algebraic-stack.
  • Supervised Fine-Tuning (SFT): MetaMath, GSM8K, and MATH datasets.
  • Formal Math: MiniF2F for evaluation and MathLib-train for LEAN tactics.
  • New Benchmarks: Evaluation on the Hungary math exam and MathBench-ZH to test generalization and multilingual proficiency.

Key Insights

  • Calculation as a Process: Training data was explicitly rewritten to decompose complex calculations (e.g., breaking $29^3$ into $(800 + 40 + 1) * 29$) to force the model to learn arithmetic algorithms rather than memorizing results.
  • LEAN as a Verifier: By translating a Chain-of-Thought into formal code, the model can use the LEAN compiler as a Reward Model to check if its informal reasoning is valid.
  • Data Scaling Limits: The authors noted that after 80B tokens of continued pre-training for the 20B model, performance on in-context learning began to plateau, suggesting a "sweet spot" for domain-specific training.

Performance Results

InternLM-Math sets a new bar for open-source mathematical LLMs. On the MATH benchmark, the InternLM-Math-20B model achieved 37.7% accuracy (greedy) and reached 50.0% when using Process Reward Model (PRM) reranking.

4-Shot MATH performance comparison showing InternLM-Math-Base 20B outperforming larger models like Llemma 34B and Minerva 62B.

Key highlights include:

  • MiniF2F: The pre-trained model achieved a score of 30.3 on the MiniF2F test set, a new state-of-the-art for open-source base models.
  • GPT-4 Parity: On several benchmarks, the models score more than 90% relative to GPT-4, despite being significantly smaller.
  • Autoformalization: The model showed a significant leap in turning word problems into formal proof statements, outperforming previous specialized models like ProofGPT.

Limitations and Future Directions

Despite these advancements, several hurdles remain:

  • Self-Critique: While the model verifies others' work well, it lacks a robust mechanism to fix its own errors during a single generation.
  • Language Bias: High-quality math data is predominantly English, leading to occasional "code-switching" in multilingual contexts.
  • LEAN Versioning: Transitioning from LEAN 3 to LEAN 4 data is a priority for future iterations.

Summary updated

BibTeX
@misc{ying2024internlm,
  author = {Huaiyuan Ying and Shuo Zhang and Linyang Li and Zhejian Zhou and Yunfan Shao and Zhaoye Fei and Yichuan Ma and Jiawei Hong and Kuikun Liu and Ziyi Wang and Yudong Wang and Zijian Wu and Shuaibin Li and Fengzhe Zhou and Hongwei Liu and Songyang Zhang and Wenwei Zhang and Hang Yan and Xipeng Qiu and Jiayu Wang and Kai Chen and Dahua Lin},
  title = {{InternLM-Math: Open Math Large Language Models Toward Verifiable Reasoning}},
  year = {2024},
  eprint = {2402.06332},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.06332},
}
Figure