MathLearner: A Large Language Model Agent Framework for Learning to Solve Mathematical Problems

Wenbei Xie, Donglin Liu, Haoran Yan, Wenjie Wu, Zongyang LiuarXiv 2024 · DOI

Introduction

While Large Language Models (LLMs) have demonstrated remarkable capabilities in natural language tasks, mathematical reasoning remains a significant challenge. A primary hurdle is the lack of human-like inductive reasoning—the ability to infer general principles from specific examples and apply them to novel contexts.

Existing Retrieval-Augmented Generation (RAG) techniques often fail in mathematics because they rely on keyword-based retrieval (e.g., BM-25). In math, two problems may share no keywords but require the same underlying theorem. The MathLearner framework addresses this by mimicking human inductive learning, extracting structural features of problems to retrieve solution strategies rather than just text.

The MathLearner Framework

MathLearner operates through a structured two-phase process designed to bridge the gap between problem description and mathematical execution.

The MathLearner framework architecture, illustrating feature extraction (1) and the retrieval-augmented generation process (2).

1. Learning Module (The "Study" Phase)

In this phase, the system processes a set of solved math problems. Using GPT-4, it translates these solutions into executable Python programs via the Parsel method. This ensures logic is grounded in code rather than probabilistic text. Crucially, the system extracts "features"—general descriptions (e.g., "geometry") and specific operations (e.g., "Pythagorean theorem")—which are stored alongside their corresponding programs in a vector database.

2. Application Module (The "Test" Phase)

When presented with a new problem, MathLearner extracts its features and performs a vector search to identify the most mathematically similar strategy in its database. The LLM then uses this retrieved knowledge as a template to generate a new Python program tailored to the current problem. This shifts the focus from keyword matching to identifying the necessary mathematical tools.

Evaluation and Results

The framework was evaluated using the MATH dataset, specifically focusing on 150 complex questions from the precalculus section. MathLearner was compared against a standard Chain-of-Thought (CoT) baseline.

  • Global Accuracy: MathLearner achieved 50% accuracy, a significant improvement over the 41.33% achieved by the CoT baseline.
  • Relative Improvement: The framework provided a 20.96% boost in problem-solving effectiveness.
  • Target Achievement: MathLearner successfully solved 17.54% of the problems that the baseline CoT method failed to solve entirely.
  • Retrieval Precision: When a similar problem was successfully retrieved, accuracy rose to 51.55%, validating the effectiveness of the feature-based retrieval mechanism.

Discussion and Future Work

MathLearner demonstrates that mathematical similarity is structural. By forcing the model to output Python code, the framework eliminates common arithmetic errors, leaving the LLM to focus on logic while the interpreter handles the calculation.

However, limitations remain. The LLM's weights do not change during this process, meaning it does not "learn" in a biological sense. Future research could involve fine-tuning models on extracted features to internalize this knowledge. Additionally, while Python is excellent for algebra, specialized solvers or natural language reasoning might be better suited for fields like geometry. The authors also aim to develop a more standardized language for mathematical features to further improve retrieval consistency.

Summary updated

BibTeX
@misc{xie2024mathlearner,
  author = {Wenbei Xie and Donglin Liu and Haoran Yan and Wenjie Wu and Zongyang Liu},
  title = {{MathLearner: A Large Language Model Agent Framework for Learning to Solve Mathematical Problems}},
  year = {2024},
  eprint = {2408.01779},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2408.01779},
}
Figure