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

An Expression Tree Decoding Strategy for Mathematical Equation Generation

Wenqi Zhang, Yongliang Shen, Qingpeng Nong, Zeqi Tan, Yanna Ma, Weiming Lu

Abstract

Solving Math Word Problems (MWP) requires translating natural language into structured mathematical equations. Traditional sequence-to-sequence or sequence-to-tree models generate these equations symbol-by-symbol or operation-by-operation, failing to capture the inherent parallel logic of mathematical reasoning. This paper introduces a novel "Expression Tree" decoding strategy that utilizes layer-wise parallel decoding. By treating equations as trees and predicting multiple independent solving steps simultaneously, the model achieves state-of-the-art accuracy while significantly reducing decoding steps.

Introduction

The task of Math Word Problem (MWP) solving involves mapping a natural language description to an executable mathematical expression. Current state-of-the-art approaches generally fall into two categories: token-level generation (Seq2Seq or Seq2Tree) and expression-level generation (Seq2Exp). While effective, these methods are fundamentally limited by their sequential nature. They predict symbols or operations one at a time in a fixed order, which does not reflect the structural logic of mathematics. In many problems, multiple sub-expressions can be calculated independently before being combined. Forcing a sequential order introduces unnecessary dependencies and increases the likelihood of error propagation in complex problems.

Methodology: Layer-wise Parallel Decoding

The proposed method shifts the paradigm from sequential generation to an "Expression Tree" structure, where each node represents a complete mathematical expression. The architecture relies on three core components:

1. Query-Based Discovery

Inspired by object detection frameworks like DETR, the model employs a set of learnable queries. Each query is responsible for identifying and extracting specific mathematical relationships from the problem's textual context. This allows the model to "look" for multiple potential operations simultaneously.

2. Parallelism and Sequential Dependency

The decoding process is organized into layers. At each layer, the model predicts multiple independent expressions (leaf nodes) in parallel. For instance, in a problem requiring the calculation of two separate distances, both can be generated in a single decoder pass. These results are then passed to subsequent layers to form "parent" nodes, effectively building the solution tree from the bottom up. This hierarchical approach ensures that while independent steps are parallelized, logical dependencies are still respected.

3. Order-Agnostic Training via Bipartite Matching

Because the model predicts multiple expressions at once, there is no inherent sequence to the predictions. To train the model effectively, the authors utilize the Hungarian Algorithm for bipartite matching. This aligns the $K$ predicted expressions with the ground-truth labels by minimizing the total loss, ensuring the model is penalized for incorrect logic rather than simply predicting the right steps in a different order than the training data.

Experimental Evaluation

The model was evaluated on three major benchmarks: MathQA (complex operations), Math23K (elementary math), and MAWPS (standard English benchmark).

Accuracy and Performance

The Expression Tree strategy achieved state-of-the-art results across the board. Notably, on the MathQA dataset—known for its complexity—the model reached 81.5% accuracy. This represents a 1.2% improvement over previous specialized models and a significant 30.8% improvement over few-shot GPT-3.5.

Decoding Efficiency

The parallel nature of the decoder drastically reduces the number of steps required to reach a solution. On MathQA, the proposed method averaged only 3.2 decoding steps, compared to 9.87 steps for Seq2Tree models and 16.74 steps for standard Seq2Seq models. This "compression" of the decoding path not only speeds up inference but also reduces the chance of cumulative errors.

Complexity Robustness

Analysis shows that the performance gap between this tree-based approach and sequential baselines widens as problems become more complex. For equations involving five or more expressions, the Expression Tree model maintains high accuracy where sequential models often fail due to the long-range dependencies required by their flat decoding structures.

Discussion and Limitations

The core insight of this work is that mathematical solutions are better represented as directed acyclic graphs or trees than as linear strings. By aligning the model architecture with this structural reality, the researchers achieved both better performance and higher efficiency.

However, some limitations remain. The maximum depth of the solution is currently constrained by the number of decoder layers. If a problem requires more sequential steps than the model has layers, it may struggle to find the correct answer. Additionally, hyperparameters such as the number of queries ($K$) must be tuned to the specific complexity of the dataset.

Conclusion

The Expression Tree decoding strategy represents a significant step forward in structured generation for mathematical reasoning. By moving away from sequential constraints and embracing parallel, layer-wise discovery, the model captures the true logic of math word problems. Future work may extend this query-based parallel strategy to other domains requiring structured logic, such as code generation or automated theorem proving.

Summary updated

BibTeX
@inproceedings{zhang2023expression,
  author = {Wenqi Zhang and Yongliang Shen and Qingpeng Nong and Zeqi Tan and Yanna Ma and Weiming Lu},
  title = {{An Expression Tree Decoding Strategy for Mathematical Equation Generation}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.emnlp-main.29},
}
Figure