Image Over Text: Transforming Formula Recognition Evaluation with Character Detection Matching

Bin Wang, Fan Wu, Linke Ouyang, Zhuangcheng Gu, Rui Zhang, Renqiu Xia, Bo Zhang, Conghui He · DOI

Abstract

Formula recognition presents significant challenges due to the complicated structure and varied notation of mathematical expressions. Despite continuous advancements in formula recognition models, the evaluation metrics employed by these models, such as BLEU and Edit Distance, still exhibit notable limitations. They overlook the fact that the same formula has diverse representations and is highly sensitive to the distribution of training data, thereby causing unfairness in formula recognition evaluation. To this end, we propose a Character Detection Matching (CDM) metric, ensuring the evaluation objectivity by designing an image-level rather than a LaTeX-level metric score. Specifically, CDM renders both the model-predicted LaTeX and the ground-truth LaTeX formulas into image-formatted formulas, then employs visual feature extraction and localization techniques for precise character-level matching, incorporating spatial position information. Such a spatially-aware and character-matching method offers a more accurate and equitable evaluation compared with previous BLEU and Edit Distance metrics that rely solely on text-based character matching. Experimentally, we evaluated various formula recognition models using CDM, BLEU, and ExpRate metrics. Their results demonstrate that the CDM aligns more closely with human evaluation standards and provides a fairer comparison across different models by eliminating discrepancies caused by diverse formula representations.

The Limitations of Text-Based Metrics

In mathematical formula recognition, the current standard for evaluation relies heavily on text-based metrics like BLEU and Edit Distance. However, these metrics suffer from a fundamental flaw: LaTeX is non-unique. A single mathematical expression can be represented by multiple, visually identical LaTeX strings (e.g., using \frac versus /, or varying bracket styles like \left( vs ().

When a model predicts a visually perfect formula that uses a different LaTeX "dialect" than the ground truth, traditional metrics penalize it unfairly. This leads to low metric reliability and biased model comparisons, where models are rewarded for mimicking the specific annotation style of a training set rather than the mathematical content itself.

Comparison of traditional text-based metrics vs. CDM across three cases of formula recognition.

As shown in the figure above, Case 1 demonstrates a visually identical prediction that receives a poor BLEU score (0.449) but a perfect CDM score (1.0). This highlights the necessity of a visual-domain metric.

The CDM Pipeline: From LaTeX to Visual Matching

To address these issues, we introduce Character Detection Matching (CDM). CDM shifts evaluation from the text domain to the visual domain through a four-stage process:

  1. Element Localization: Rather than using a standard black-and-white render, CDM renders each LaTeX token (e.g., \alpha, +, \sin) in a unique RGB color. This allows the system to extract the exact bounding box for every character automatically, bypassing the need for an external, error-prone detection model.
  2. Element Region Matching: Using the Hungarian Algorithm, the system finds the optimal pairing between characters in the predicted image and the ground truth, considering token type and spatial coordinates.
  3. Invalid Match Elimination: To ensure structural integrity, a RANSAC-based spatial check is applied. Matches are discarded if characters appear in incorrect relative positions, ensuring that the "math" makes sense spatially.
  4. Metric Calculation: The final score is an F1-score based on matched character pairs. We also introduce ExpRate@CDM, measuring the percentage of formulas that achieve perfect visual recognition.
Step 1 of the CDM process: Element Localization via color-coded rendering.

Experimental Results and Insights

We evaluated CDM using the UniMER-Test dataset (23,000+ formulas) and a new benchmark, Tiny-Doc-Math, consisting of formulas from recent arXiv papers to test generalization beyond training data distributions.

Key findings include:

  • Human Alignment: In user preference studies, 64% of participants preferred CDM over BLEU for accuracy in reflecting recognition quality.
  • Robustness to Style: CDM remains stable (score of 1.0) even when the underlying LaTeX code is rewritten in multiple ways, whereas BLEU scores fluctuate wildly.
  • Identifying Hallucinations: When testing Large Language Models like GPT-4o, CDM successfully identified small but critical structural errors that text-based metrics often overlooked.

Conclusion

CDM provides a fairer, more objective standard for formula recognition by prioritizing visual truth over textual representation. By eliminating the bias inherent in LaTeX coding styles, CDM allows researchers to focus on improving the actual recognition capabilities of their models. The code and metric are available at https://github.com/opendatalab/UniMERNet/tree/main/cdm.

Summary updated

BibTeX
@inproceedings{wang2025image,
  author = {Bin Wang and Fan Wu and Linke Ouyang and Zhuangcheng Gu and Rui Zhang and Renqiu Xia and Bo Zhang and Conghui He},
  title = {{Image Over Text: Transforming Formula Recognition Evaluation with Character Detection Matching}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.01833},
}
Figure