Generating Math Word Problems from Equations with Topic Controlling and Commonsense Enforcement

Tianyang Cao, Shuang Zeng, Songge Zhao, Mairgup Mansur, Baobao Chang

Abstract

Generating coherent math word problems (MWPs) from abstract equations is a challenging "inverse problem" in natural language processing. Unlike solving MWPs, generation requires bridging the gap between symbolic logic and descriptive storytelling while maintaining logical consistency. This paper introduces a novel framework that combines a template-aware equation encoder with a Variational AutoEncoder (VAE) to map math tokens into a text-sensitive latent space. To ensure narrative quality, the model incorporates Latent Dirichlet Allocation (LDA) for topic control and external knowledge graphs (ConceptNet5) for commonsense enforcement. Experimental results on a newly curated benchmark of 14,943 equation-problem pairs demonstrate significant improvements in BLEU scores and human-rated coherence over standard sequence-to-sequence baselines.

Introduction

The "inverse problem" of math word problem (MWP) solving—generating a human-readable story from a set of equations—presents a unique challenge in data-to-text generation. While AI has made strides in solving MWPs, generating them requires the model to invent a context that is both mathematically accurate and linguistically natural. Researchers from Peking University and Sogou Technology address this by proposing a framework that mitigates common pitfalls like topic drifting and logical absurdities.

Challenges in MWP Generation

The authors identify three primary hurdles that hinder standard sequence-to-sequence (Seq2Seq) models in this domain:

  1. Abstract Representation: Math equations (numbers, variables, operators) are highly abstract compared to the rich, descriptive language used in word problems.
  2. Topic Drifting: Models often fail to maintain a consistent narrative, switching contexts (e.g., from prices to chemical mixtures) mid-problem.
  3. Commonsense Violations: Without external grounding, models may generate nonsensical statements, such as asking for the "hypotenuse of a square" or the "dimensions of a number."
Examples of the MWP generation task and common failure cases in baseline models.

Proposed Methodology

The proposed architecture uses a multi-layered approach to bridge the symbolic-linguistic divide.

Template-Aware Equation Encoder

To focus on the underlying logic rather than specific values, the model uses a soft gate mechanism. It creates an equation "template" by masking numbers (e.g., $x + 5 = 10$ becomes $x + [M] = [M]$). Both the original equation and its template are processed via a Bi-directional Gated Recurrent Unit (BiGRU), allowing the model to learn that relationships between variables are more important for storytelling than the specific values.

Problem-Aware VAE

A Variational AutoEncoder maps abstract math tokens into a latent space that is more sensitive to textual nuances. This helps the decoder transition more smoothly from mathematical symbols to natural language sentences.

Topic Selection and Control

Using LDA, the model categorizes problems into nine distinct topics (e.g., geometry, interest rates). A Topic Selector designates a fixed theme for the problem, while a Topic Controller employs a dynamic memory mechanism to ensure word choices remain within the chosen thematic "lane," preventing the narrative from wandering.

Commonsense Enforcement

To prevent logical errors, the authors leverage ConceptNet5, a massive knowledge graph. Word embeddings are pre-trained using a Graph Attention Network (GAT). The "Commonsense Aware Generator" examines neighboring nodes in the knowledge graph to influence decoding, ensuring that terms like "triangle" are associated with "sides" or "angles" rather than unrelated geometric properties.

The overall architecture of the proposed model, featuring the template-aware encoder, VAE, and commonsense knowledge graph enforcement.

Dataset and Evaluation

Finding existing datasets like Dolphin-18K insufficient, the researchers crawled Yahoo! to extend the data, creating a benchmark of 14,943 equation-problem pairs. This dataset features more complex equations (average 16.64 tokens) and a wider variety of operators compared to previous benchmarks.

The model was evaluated against baselines like Seq2Seq, SeqGAN, and Transformers:

  • Automatic Metrics: The model achieved a BLEU score of 0.0433, a significant relative improvement over the standard Seq2Seq (0.0259).
  • Ablation Studies: Removing the commonsense module led to a 24.4% drop in BLEU score, highlighting the critical role of external knowledge.
  • Human Evaluation: Annotators rated the model higher in Coherence (4.02/5) and Solvability (35% vs. 23% for Seq2Seq).

Conclusion

This work demonstrates that incorporating structural templates, topic anchors, and knowledge graphs can significantly enhance the quality of generated math word problems. While the "solvability gap" remains—with only 35% of problems being perfectly solvable—this research provides a robust foundation for future work in complex logic-to-text generation.

Summary updated

BibTeX
@inproceedings{cao2021generating,
  author = {Tianyang Cao and Shuang Zeng and Songge Zhao and Mairgup Mansur and Baobao Chang},
  title = {{Generating Math Word Problems from Equations with Topic Controlling and Commonsense Enforcement}},
  booktitle = {ICANN},
  year = {2021},
  doi = {10.1007/978-3-030-86365-4\_6},
}
Figure