NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Math2Sym: A System for Solving Elementary Problems via Large Language Models and Symbolic Solvers

Minh Phu Nguyen, Minh Phuong Pham, Man Ngo, Kha Tuan MinhMATH-AI @ NeurIPS 2024

TL;DR

This paper introduces Math2Sym, a novel system that combines Large Language Models (LLMs) with symbolic solvers to tackle math word problems (MWPs). By translating natural language problems into precise symbolic forms, Math2Sym aims to overcome the limitations of LLMs in arithmetic reasoning and improve accuracy. The system also introduces the EMSF dataset for training and evaluation, demonstrating competitive performance against state-of-the-art models.

What Problem Does This Paper Address?

Solving math word problems (MWPs) is a significant challenge in artificial intelligence, requiring a blend of linguistic comprehension and robust mathematical reasoning. Traditional approaches often struggle to accurately interpret the nuances of natural language descriptions and translate them into precise mathematical operations, especially for complex problems. While recent advancements like Chain-of-Thought prompting and Program-Aided Language models have shown promise, they still face limitations in handling intricate arithmetic and ensuring computational accuracy. This paper addresses the gap by proposing a system that leverages the strengths of both LLMs (for language understanding) and symbolic solvers (for precise computation) to create a more effective MWP solving pipeline.

Methods

The core of Math2Sym lies in its two-pronged approach:

  • LLM-based Formalization: Math2Sym utilizes LLMs to process natural language MWPs and convert them into a standardized "Symbolic Form." This process involves three key steps:
  • Extraction of Variables: Identifying relevant entities, constants, and relationships within the problem description.
  • Formulation of Mathematical Expressions: Translating these extracted elements into precise mathematical expressions that adhere to the problem's logic.
  • Conversion to Symbolic Form: Representing these expressions in a structured format compatible with a symbolic solver. Crucially, the LLM is trained to formalize the problem rather than compute the solution directly, mitigating common arithmetic errors.

  • Symbolic Solver Integration: The generated Symbolic Form is then passed to an external symbolic solver (built using Python's SymPy library). This solver handles all the actual mathematical computations, ensuring accuracy and precision. The Symbolic Form is structured as [[constants or expressions, variables, actions]], where the "actions" correspond to specific SymPy methods (e.g., 'solve', 'igcd').

Datasets

The paper introduces the EMSF dataset for training and evaluating models on math word problem formalization. This dataset is designed to cover various complexities and problem types. It consists of three parts:

  • Pretrain: Focuses on standard mathematical formalization without natural language.
  • Basic: Synthetically generated using Mixtral 8x7B, involving direct extraction of simple problem elements. This dataset contains 149,000 samples covering inequalities, systems of equations, and GCD/LCM problems.
  • Advanced: Generated using LLaMA3 70B, requiring more complex reasoning steps and information aggregation. This dataset comprises 79,000 samples, including percentage interest problems, and is more intricate than the basic dataset.

The authors also mention using a custom test dataset of 92 questions across five categories (GCD, LCM, systems of equations, linear inequalities, compound inequalities) with varying difficulty levels.

Key Insights and Ideas

  • Decoupling Reasoning and Computation: The most significant insight is the separation of linguistic understanding and arithmetic computation. By training LLMs to generate symbolic representations and delegating calculations to a dedicated symbolic solver, Math2Sym effectively addresses the LLMs' inherent weaknesses in precise arithmetic.
  • Symbolic Form as a Universal Translator: The structured Symbolic Form acts as a crucial intermediary, enabling LLMs to communicate complex mathematical problems to a computational engine in a standardized, unambiguous way.
  • Dataset Complexity Matters: The research highlights that the complexity of the training dataset significantly impacts model performance. Smaller models might perform well on simpler datasets, but larger models are necessary to handle the intricacies of advanced reasoning problems.
  • Fine-tuning for Formalization is Key: Fine-tuning LLMs on datasets specifically designed for problem formalization (like EMSF) leads to superior performance compared to zero-shot or few-shot prompting alone, especially when integrated with a symbolic solver.

Key Results

  • Enhanced Performance with Solver Integration: Integrating symbolic solvers with LLMs significantly boosted performance across various models. For instance, Mistral 7B showed a 37% improvement with solver integration compared to Few-Shot PaL.
  • Competitive Performance: Fine-tuned models on the EMSF dataset outperformed GPT-3.5 by 17% in few-shot tasks and performed comparably to GPT-4-mini on elementary math problems.
  • WizardMath 7B Excels: The WizardMath 7B model, fine-tuned on the advanced dataset, achieved a score of 217, outperforming zero-shot CoT (133) and GPT-3.5-turbo's best in-context learning (179) on high-difficulty problems.
  • Model Size and Dataset Alignment: The study shows that while smaller models can be efficient for simpler tasks, larger models are crucial for complex problems. Furthermore, aligning dataset complexity with model capacity is vital for optimal performance.

Limitations and Future Work

  • Dataset Size and Scope: While the EMSF dataset is substantial, future work could explore expanding it to include an even wider range of mathematical problem types and complexities.
  • Generalization to More Complex Domains: The current focus is on elementary math problems. Extending Math2Sym to handle more advanced mathematical concepts (e.g., calculus, linear algebra) would be a valuable next step.
  • LLM Capabilities: The performance is still dependent on the LLM's ability to accurately extract and formulate information. Further research into improving LLM comprehension and reducing hallucination in problem formulation could enhance the system.
  • Symbolic Solver Efficiency: While SymPy is powerful, exploring more specialized or optimized symbolic solvers for specific problem domains could potentially lead to further speedups.

Summary updated

BibTeX
@inproceedings{nguyen2024math,
  author = {Minh Phu Nguyen and Minh Phuong Pham and Man Ngo and Kha Tuan Minh},
  title = {{Math2Sym: A System for Solving Elementary Problems via Large Language Models and Symbolic Solvers}},
  booktitle = {MATH-AI @ NeurIPS},
  year = {2024},
  url = {https://openreview.net/forum?id=eQrkAPcGRF},
}
Figure