Abstract
Math Word Problem (MWP) is a crucial NLP task aimed at providing solutions for given mathematical descriptions. A notable sub-category of MWP is the Linear Programming Word Problem (LPWP), which holds significant relevance in real-world decision-making and operations research. While the recent rise of generative large language models (LLMs) has brought more advanced solutions to LPWPs, existing evaluation methodologies for this task still diverge from human judgment and face challenges in recognizing mathematically equivalent answers. In this paper, we introduce a novel evaluation metric rooted in graph edit distance, featuring benefits such as permutation invariance and more accurate program equivalence identification. Human evaluations empirically validate the superior efficacy of our proposed metric when particularly assessing LLM-based solutions for LPWP.
Introduction: A Better Yardstick for Linear Programming LLMs
Evaluating how well Large Language Models (LLMs) solve math problems is notoriously difficult. While a simple arithmetic problem has a single "right" answer, Linear Programming Word Problems (LPWPs)—the kind used in logistics and resource management—are far more complex. A model might produce a mathematically identical program to the ground truth but use different variable names or list constraints in a different order, causing standard evaluation metrics to fail.
In their LREC-COLING 2024 paper, researchers from Huawei, SFU, and UBC propose a more "human-aligned" way to grade these models using graph theory. Their approach ensures that evaluation is invariant to the order of variables and constraints while remaining highly correlated with human expert judgment.
The Problem: Beyond Simple Arithmetic
Linear Programming (LP) involves maximizing or minimizing an objective function subject to a set of linear constraints. When an LLM translates a word problem into an LP program, we need to know if it captured the underlying mathematical logic correctly.
Existing metrics fall into two primary traps:
- Canonical Accuracy: This checks if the predicted text matches the reference text. However, if the model swaps the order of two constraints (e.g., listing $x + y \leq 50$ before $x \geq 5$), the metric penalizes it, even though the math is identical. This is known as a lack of permutation invariance.
- Execution Accuracy: This checks if the predicted program yields the same numerical answer as the reference. The danger here is "false positives." Two completely different (and incorrect) programs might both be "infeasible" or happen to hit the same optimal value by chance, leading the metric to incorrectly label a failure as a success.
Methodology: Optimization Problems as Graphs
The authors propose a three-step pipeline to evaluate LPWPs using Normalized Graph Edit Distance (NGED):
- Standardization: A rule-based parser converts the LLM's textual output into a "general form" (a standard matrix representation).
- Graph Representation: The LP problem is represented as an attributed bipartite graph. One set of nodes represents constraints, and the other represents decision variables. Edges represent the coefficients in the constraint matrix. Attributes like lower/upper bounds and objective coefficients are attached to the nodes.
- Graph Matching: The Graph Edit Distance (GED) is calculated—the minimum "cost" to transform the predicted graph into the reference graph. By treating the problem as a graph, the specific order in which the model wrote the variables or constraints no longer matters.
Key Insights and Results
- Permutation Invariance is Non-Negotiable: In optimization, the sequence of constraints is arbitrary. By moving from string matching to graph matching, the authors solve this fundamental flaw.
- Structural vs. Functional Correctness: Execution accuracy only cares about the "output" (functional). NGED cares about the "logic" (structural). For reliability, it is vital to know if the model built the correct logic, not just if it stumbled upon the right number.
- Alignment with Experts: When Operations Research (OR) experts ranked model outputs, their rankings matched the NGED metric far more often than they matched Canonical or Execution accuracy. The proposed NGED metric achieved a C-Match of 178/289, dwarfing Canonical Accuracy (64/289) and Execution Accuracy (9/289).
Conclusion
While calculating exact Graph Edit Distance is computationally complex (NP-hard), it remains manageable for typical LPWPs. This research provides a more robust framework for evaluating LLMs in specialized domains like operations research. Future work may involve using approximate GED algorithms to handle larger industrial-scale problems or using this metric as a reward function for Reinforcement Learning from Human Feedback (RLHF) to train more mathematically rigorous models.
Summary updated