Translating a Math Word Problem to an Expression Tree

Lei Wang, Yan Wang, Deng Cai, Dongxiang Zhang, Xiaojiang LiuarXiv 2018

Abstract

Math word problem (MWP) solving is often hindered by the non-deterministic nature of equation generation, where multiple mathematically equivalent expressions can represent a single problem. This paper introduces an equation normalization method based on expression trees and utilizes an ensemble of diverse SEQ2SEQ architectures—Bi-LSTM, ConvS2S, and Transformer. By canonicalizing target sequences through postorder traversal and applying specific ordering rules, the proposed framework achieves a state-of-the-art accuracy of 68.4% on the Math23K dataset.

Introduction

Solving Math Word Problems (MWPs) automatically requires a system to interpret a natural language description (e.g., "Dan has 5 pens...") and generate a corresponding mathematical expression. While Sequence-to-Sequence (SEQ2SEQ) models have shown promise in "translating" text into equations, they face a significant hurdle: equation duplication.

A single problem can often be solved by multiple equivalent equations, such as $x = 5 + 4 + 3 - 2$ and $x = 4 + (5 - 2) + 3$. To a standard machine learning model, these appear as distinct target sequences. This "one-to-many" mapping creates a noisy, non-deterministic output space that complicates training and degrades performance.

Methods

The researchers propose a two-stage framework enhanced by a novel normalization step to address these challenges.

1. Number Mapping and Equation Normalization

Numbers in the text are first replaced with tokens ($n_1, n_2, \dots$) based on their order of appearance. To ensure the model learns a unique canonical representation, three normalization rules are applied:

  • Rule 1 (Length): The shortest version of an equation is preferred.
  • Rule 2 (Order): Number tokens are ordered as closely as possible to their appearance in the text (e.g., preferring $n_1 + n_2$ over $n_2 + n_1$).
  • Rule 3 (Expression Trees): Equations are converted into expression trees. By using the postorder traversal of these trees as the target sequence, the model eliminates ambiguities caused by brackets.

2. Model Ensemble

Recognizing that different architectures possess unique strengths, the authors trained three distinct SEQ2SEQ models:

  • Bi-LSTM: Excels at capturing sequential dependencies.
  • ConvS2S: Utilizes convolutional layers to capture local context.
  • Transformer: Employs self-attention to manage long-range relationships and complex inference.
The SEQ2SEQ architecture for MWP solving, illustrating the flow from text embedding to postorder traversal output.

The final output is selected from the model that yields the highest generation probability.

Experimental Results

The study utilized the Math23K dataset, containing 23,162 labeled math word problems. The results demonstrate that equation normalization (EN) provides a substantial performance boost across all architectures.

Performance comparison showing accuracy gains with and without Equation Normalization (EN).

Key Findings

  • Normalization Impact: For the Bi-LSTM model, accuracy increased from 59.6% to 66.7% solely due to the application of normalization rules.
  • State-of-the-Art Performance: The ensemble model achieved a final accuracy of 68.4%, significantly outperforming previous benchmarks like DNS-Hybrid (58.1%).
  • Architectural Diversity: The Transformer proved better at complex inference but occasionally generated invalid templates, whereas Bi-LSTM and ConvS2S were more robust for standard problems.

Conclusion

The primary insight of this work is that the difficulty of MWP solving lies not just in linguistic understanding, but in the mathematical symmetry of the output. By forcing the model to learn a unique "canonical" expression tree through postorder traversal, the authors reduced the search space and clarified the learning objective. Future work may extend these methods to multi-variable systems, geometry, and calculus.

Summary updated

BibTeX
@misc{wang2018translating,
  author = {Lei Wang and Yan Wang and Deng Cai and Dongxiang Zhang and Xiaojiang Liu},
  title = {{Translating a Math Word Problem to an Expression Tree}},
  year = {2018},
  eprint = {1811.05632},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1811.05632},
}
Figure