Recall and Learn: A Memory-augmented Solver for Math Word Problems

Shifeng Huang, Jiawei Wang, Jiao Xu, Da Cao, Ming Yang

Introduction

Solving Math Word Problems (MWPs) involves translating natural language into executable mathematical expressions. Traditional "template-based" approaches often suffer from cumulative errors in a two-stage process: predicting a formula template and then filling it with numbers. Furthermore, these models typically rely on inductive learning across a dataset, failing to leverage the analogical reasoning humans use—recalling similar past problems to solve new ones.

The REAL (REcall And Learn) framework addresses these limitations by integrating a memory-augmented architecture that retrieves and learns from similar historical examples to guide the solution of novel problems.

Methodology: The REAL Framework

The REAL framework consists of four integrated modules designed to mimic human analogical reasoning:

  1. Memory Module: Utilizes Maximum Inner Product Search (MIPS) to retrieve the top-$K$ most similar problems from the training set based on textual similarity.
  2. Representation Module: A Transformer-based encoder that converts both the target problem and retrieved reference problems into vector representations.
  3. Analogy Module: The core innovation, using a Transformer network with a specific causal mask. This allows the model to attend to the retrieved problem's solution while generating the current one, facilitating "learning by example."
  4. Reasoning Module: A decoder with a copy mechanism that can either generate mathematical operators or directly copy quantities from the problem description.
The architecture of the REAL framework, illustrating the interaction between Memory, Representation, Analogy, and Reasoning modules.

The model is trained with a dual-loss objective: an analogical loss for the target problem and an inductive loss for the retrieved reference questions, ensuring a deep understanding of the source material.

Experimental Results

The REAL framework was evaluated on two major benchmarks: Math23K (23,162 problems) and Ape210K (over 210,000 problems). REAL achieved state-of-the-art (SOTA) performance on both, significantly outperforming previous models.

Comparison of REAL against previous state-of-the-art models on Math23K and Ape210K datasets.

As shown in the results, REAL reached 82.3% accuracy on Math23K and 77.18% on Ape210K, marking a substantial improvement over existing baselines like Graph2Tree and Ape.

Analysis and Insights

  • Analogy as a Regularizer: Recalling similar problems proves highly effective for complex, long-expression problems where inductive models often fail.
  • Scaling with $K$: Accuracy improves as the number of retrieved examples ($K$) increases, though benefits plateau after $K=4$.
  • Common Sense Gaps: REAL helps bridge "common sense" gaps (e.g., distinguishing area from volume) by providing structural logic from retrieved examples.
  • Noise Sensitivity: For simple "Easy" problems, the retrieval of "similar but not identical" problems can occasionally introduce noise, making pure induction slightly more robust in those specific cases.

Limitations and Future Work

While effective, the current framework relies on a pre-trained, separate retriever. Future work could involve jointly training the retriever and solver to ensure mathematical rather than just textual similarity. Additionally, the computational overhead of processing $K$ additional problems per inference step remains a challenge for real-time deployment.

Summary updated

BibTeX
@inproceedings{huang2021recall,
  author = {Shifeng Huang and Jiawei Wang and Jiao Xu and Da Cao and Ming Yang},
  title = {{Recall and Learn: A Memory-augmented Solver for Math Word Problems}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  doi = {10.18653/v1/2021.findings-emnlp.68},
}
Figure