Bidirectional trained tree-structured decoder for Handwritten Mathematical Expression Recognition

Hanbo Cheng, Chenyu Liu, Pengfei Hu, Zhenrong Zhang, Jiefeng Ma, Jun Du

Handwritten Mathematical Expression Recognition (HMER) is a notoriously difficult subset of OCR. Unlike standard text, math is non-linear—it’s a two-dimensional puzzle of superscripts, subscripts, and nested fractions. In a recent paper, researchers from the University of Science and Technology of China introduce a novel framework that brings the power of bidirectional training to tree-structured decoders, setting new benchmarks in the field.

TL;DR

The authors propose a Bidirectional Asynchronous Training (BAT) strategy for tree-structured decoders, enabled by a new Mirror-Flipped Symbol Layout Tree (MF-SLT) representation. By combining this with a Shared Language Modeling (SLM) mechanism, their model achieves state-of-the-art results on the CROHME and HME100K datasets, significantly improving the recognition of visually ambiguous symbols and complex structures.

What Problem Does This Paper Address?

HMER models generally fall into two camps: String Decoders (SD), which treat math as a LaTeX sequence, and Tree Decoders (TD), which model the 2D spatial relationships between symbols. While string decoders are great at learning "linguistic" patterns (the grammar of math), they struggle with complex 2D layouts. Tree decoders excel at structure but often lack strong language modeling capabilities.

Furthermore, "bidirectional" training—looking at an expression from both left-to-right and right-to-left—has proven highly effective for strings. However, applying this to trees is difficult because there is no obvious way to "reverse" a tree structure. This leaves tree decoders at a disadvantage when dealing with visual ambiguity (e.g., a messy "z" looking like a "2").

Methods

The authors introduce three key innovations to bridge this gap:

  1. Mirror-Flipped Symbol Layout Tree (MF-SLT): To enable bidirectional training for trees, the authors designed a way to "flip" the 2D structure. By redefining the "Main Path" and reversing relationships (e.g., turning "Right" into "Left"), they created a valid right-to-left tree representation that maintains semantic consistency.
  2. Bidirectional Asynchronous Training (BAT): Instead of just training two separate decoders, BAT allows them to talk. An R2L decoder first processes the image; then, an L2R decoder uses the hidden states of the R2L pass as "future" context. This is handled by a Hidden state Attention Module (HAM), allowing the model to "look ahead" while decoding.
  3. Shared Language Modeling (SLM): To boost linguistic perception, the authors added a "language-only" branch to the decoder that shares parameters with the main branch but receives no visual input. This forces the model to learn the underlying probability of symbol sequences (the "language" of math) without relying solely on the image.

Datasets

The model was evaluated on two major benchmarks:

  • CROHME (2014, 2016, 2019): The standard competition datasets for HMER, containing roughly 8,800 training images.
  • HME100K: A much larger, real-world dataset with 74,502 training images featuring realistic noise, distortions, and a wider variety of symbols (245 categories).

Key Insights and Ideas

  • The Data-Linguistic Correlation: One of the most interesting findings is that as the volume of training data increases, the importance of linguistic perception grows. In small datasets, models rely on "memorizing" visual cues; in large datasets, they benefit significantly from understanding the "grammar" of how symbols relate.
  • Fixing the "Weak Tail": Standard decoders often lose accuracy toward the end of an expression. By incorporating the R2L context, the BAT strategy significantly boosts accuracy for the suffixes of mathematical expressions.
  • Efficiency: The SLM mechanism improves performance without adding any extra parameters during the inference (testing) stage, as the language-only branch is only used during training to "guide" the shared parameters.

Key Results

The proposed BAT-TDv2 model achieved impressive gains over the baseline:

  • CROHME 2014/2016: Reached an Expression Recognition Rate (ExpRate) of 60.34% and 60.50%, respectively—a jump of over 5% compared to the baseline TDv2.
  • HME100K: Achieved 68.66% ExpRate, outperforming all previous state-of-the-art methods.
  • Ablation Studies: The results showed that BAT and SLM are complementary; using both yielded the highest accuracy, particularly in resolving "visual confusion" cases like distinguishing between a decimal point and a comma in context.

Limitations and Future Work

  • The Recognition Bottleneck: The authors note that while their structural analysis is strong, the primary bottleneck remains individual symbol recognition. If the model misidentifies a character, the whole expression often fails.
  • Greedy Search: The current results were achieved using a simple greedy search during inference. The authors suggest that more sophisticated search strategies or fusion methods could further improve results.
  • GCN Integration: While the model is a tree decoder, the authors mention that integrating Graph Convolutional Networks (GCNs) could be a promising direction to further enhance the spatial relationship modeling.

Summary updated

BibTeX
@article{cheng2025bidirectional,
  author = {Hanbo Cheng and Chenyu Liu and Pengfei Hu and Zhenrong Zhang and Jiefeng Ma and Jun Du},
  title = {{Bidirectional trained tree-structured decoder for Handwritten Mathematical Expression Recognition}},
  journal = {Pattern Recognition},
  year = {2025},
  doi = {10.1016/j.patcog.2025.111599},
}
Figure