MathDQN: Solving Arithmetic Word Problems via Deep Reinforcement Learning

Lei Wang, Dongxiang Zhang, Lianli Gao, Jingkuan Song, Long Guo, Heng Tao Shen

Abstract

MathDQN is a novel framework that applies Deep Reinforcement Learning (DRL) to solve arithmetic word problems by modeling the construction of mathematical expression trees as a sequential decision-making task. By navigating the search space of possible equations more intelligently than traditional brute-force or heuristic methods, MathDQN achieves a 15% average precision boost over previous state-of-the-art models, particularly excelling in complex multi-step problems.

Introduction

Solving Math Word Problems (MWPs) is a classic challenge in artificial intelligence, requiring a combination of natural language understanding and logical reasoning. Traditional approaches often rely on tree-based methods that identify numbers in a text and attempt to construct an expression tree to derive the answer. However, as the number of quantities in a problem increases, the search space for possible trees grows exponentially. Previous models typically employed "beam search" to prune this space, but such rigid heuristics frequently miss the correct solution.

Example of a Math Word Problem and its corresponding expression tree.

MathDQN addresses these limitations by replacing fixed search heuristics with a flexible, learning-based agent. By viewing equation building as a sequence of actions, the model learns to identify promising sub-expressions, optimizing the entire sequence of operations rather than evaluating a completed tree in isolation.

Methods

The MathDQN framework utilizes a Deep Q-Network (DQN) to build expression trees step-by-step. The process involves several key stages:

Quantity Extraction and Re-ordering

The system first identifies numerical values within the problem text. A "re-order" mechanism, based on "rate units" (e.g., "dollars per hour"), is used to prioritize numbers that are likely to be operated on first, streamlining the initial search.

State Representation and Action Space

The "state" is represented as a feature vector for a pair of quantities, incorporating individual features (associated verbs, rate units), pair features (unit matching, relative magnitude), and question-level features (keywords like "more," "less," or "each").

The agent selects from six possible actions for any given pair: addition (+), multiplication (×), subtraction (−), division (÷), and "reverse" versions of subtraction and division. These reverse operators (e.g., $a \div_{inv} b = b \div a$) allow the agent to handle non-commutative operations correctly regardless of the order in which numbers appear in the text.

Deep Q-Network and Training

A two-layer feed-forward neural network processes the state vector to predict "Q-values," representing the expected future reward for each operator. During training, the agent receives positive reinforcement for selecting the correct operator and negative rewards for incorrect choices, enabling it to learn the optimal policy for tree construction.

Results and Discussion

MathDQN was evaluated on standard benchmarks including AI2, IL, CC, and the ArithS/ArithM subsets.

Performance and Efficiency

The model demonstrated a significant performance leap, improving average precision across all datasets by 15% compared to the previous state-of-the-art (UnitDep). Notably, on the ArithM dataset—comprising the most difficult multi-step problems—MathDQN achieved 76.0% accuracy, a substantial increase from the previous record of 52.9%.

Furthermore, MathDQN is highly efficient, solving problems in approximately 9 milliseconds. This makes it significantly faster than older algorithmic methods like ALGES, which can take over a second per problem.

Limitations and Future Directions

Despite its success, MathDQN has limitations. It relies on an external syntax parser; if the parser fails to identify a number (e.g., "two" vs. "2"), the model cannot proceed. Additionally, the input features are currently hand-crafted based on linguistic rules. Future work may involve using Recurrent Neural Networks (RNNs) or Transformers to learn features directly from raw text. Finally, the current state representation focuses on pairs of numbers; capturing the "global" state of a complex, partially built tree may be necessary for solving more advanced algebraic or calculus problems.

Conclusion

MathDQN represents a significant step forward in automated math problem solving. By framing the task as a reinforcement learning problem, it overcomes the scalability issues of traditional search methods, providing a robust and efficient solution for multi-step arithmetic reasoning.

Summary updated

BibTeX
@inproceedings{wang2018mathdqn,
  author = {Lei Wang and Dongxiang Zhang and Lianli Gao and Jingkuan Song and Long Guo and Heng Tao Shen},
  title = {{MathDQN: Solving Arithmetic Word Problems via Deep Reinforcement Learning}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2018},
  doi = {10.1609/aaai.v32i1.11981},
}
Figure