Abstract
Mathematical Formula Recognition (MFR) is the task of converting images of equations into machine-readable code, typically LaTeX. However, traditional text-based evaluation metrics like BLEU and Edit Distance often fail due to the "one-to-many" nature of LaTeX, where a single visual formula can be represented by multiple valid strings. This paper introduces Character Detection Matching (CDM), a novel metric that evaluates formulas based on their rendered visual output rather than their underlying code. By matching individual characters spatially, CDM provides a more reliable, fair, and human-aligned evaluation framework for the MFR community.
Introduction
Evaluating MFR models has historically relied on string-matching metrics. These metrics are problematic because LaTeX is syntactically diverse; for example, x^{a}_{b} and x_{b}^{a} render identically but differ in text representation. This leads to three primary issues: low reliability where visually perfect formulas receive low scores, unfair comparisons between models using different LaTeX "dialects," and a lack of intuition where minor syntactic typos can render a formula unreadable while maintaining high string similarity.
Methodology: The CDM Pipeline
To address these limitations, the authors propose treating formula evaluation as an image-based object detection task. The CDM process consists of four distinct stages:
- Element Localization: Instead of relying on error-prone OCR, the system renders the predicted and ground-truth LaTeX strings into images. Each token is rendered in a unique RGB color, allowing for the extraction of precise, "perfect" bounding boxes for every character.
- Element Region Matching: The algorithm pairs characters from the prediction with the ground truth using the Hungarian Algorithm. The matching cost considers token identity, spatial proximity, and the original code order.
- Invalid Match Elimination: To ensure structural integrity, the metric applies a RANSAC-based affine transformation check and position relationship consistency checks. This filters out accidental matches that do not fit the global spatial structure of the equation.
- Metric Calculation: The final score is an F1-score derived from matched character pairs. The authors also propose ExpRate@CDM, where a formula is only considered correct if it achieves a perfect CDM score of 1.0.
Experimental Results and Insights
CDM was benchmarked using the UniMER-Test dataset and a new Tiny-Doc-Math dataset curated from recent arXiv papers to prevent data leakage. The results highlight several key advantages of the visual-first approach:
- Human Alignment: In user studies, CDM showed a 96% consistency rate with human subjective judgment, with 64% of participants preferring it over traditional metrics like BLEU.
- Syntactic Invariance: When formulas were rewritten into visually identical but syntactically different LaTeX styles, CDM scores remained a perfect 1.0, while BLEU scores fluctuated significantly.
- Model Performance: Benchmarking revealed that models like UniMERNet and Mathpix lead the field. Interestingly, modern multimodal LLMs like GPT-4o often produce visually accurate formulas that are unfairly penalized by text metrics for adding or omitting minor punctuation (e.g., periods or commas).
Conclusion
Character Detection Matching (CDM) represents a paradigm shift in MFR evaluation by establishing the rendered image as the source of truth. By eliminating the "unfair" penalties associated with LaTeX's representational diversity, CDM enables more accurate benchmarking of both traditional encoder-decoder models and modern multimodal LLMs. Future work may involve integrating CDM directly into model training as a loss function to optimize for visual fidelity.
Summary updated