Handwritten Mathematical Expression Recognition via Attention Aggregation Based Bi-directional Mutual Learning

Xiaohang Bian, Bo Qin, Xiaozhe Xin, Jianwu Li, Xuefeng Su, Yanfeng Wang

Introduction

Handwritten Mathematical Expression Recognition (HMER) presents a unique challenge in computer vision and sequence generation. Unlike standard text, mathematical expressions are inherently non-linear, featuring complex two-dimensional structures such as superscripts, subscripts, and nested fractions. Furthermore, the symbols themselves exhibit significant scale variance—ranging from small punctuation marks to large integral or summation signs.

Traditional encoder-decoder models typically generate LaTeX sequences in a left-to-right (L2R) manner. However, this approach often suffers from "attention drift" in long sequences and fails to leverage future context that could disambiguate current symbols.

The ABM Framework

To address these limitations, researchers have introduced the Attention aggregation based Bi-directional Mutual learning (ABM) network. This framework enhances the standard encoder-decoder paradigm through two primary innovations: multi-scale attention and bi-directional mutual learning.

Comparison of ABM with existing HMER architectures.

As shown in the architectural comparison above, ABM distinguishes itself by incorporating both bi-directional decoding and a specialized attention aggregation module, moving beyond the simple L2R or basic bi-directional models of the past.

Core Components

The ABM architecture consists of three integrated modules:

  1. Feature Extraction Module (FEM): A DenseNet-based backbone extracts high-level spatial features from the input image.
  2. Attention Aggregation Module (AAM): Standard attention mechanisms often struggle with scale variance. AAM employs multi-scale convolution kernels (e.g., 5x5 and 11x11) to process coverage attention. This allows the model to simultaneously capture fine-grained details for small symbols and broader context for larger structural elements.
  3. Bi-directional Mutual Learning (BML): This module employs two parallel decoders—one generating the sequence from left-to-right (L2R) and the other from right-to-left (R2L). During training, these decoders are synchronized via mutual distillation, minimizing the Kullback-Leibler (KL) divergence between their probability distributions. This process allows the L2R decoder to "learn" from the future context captured by the R2L decoder.
Detailed overview of the ABM architecture, including FEM, BML, and AAM modules.

A key advantage of this approach is its efficiency: during inference, the R2L branch is discarded, allowing the model to benefit from bi-directional training while maintaining the parameter size and speed of a standard single-direction model.

Experimental Results

The ABM framework was evaluated on the CROHME 2014, 2016, and 2019 benchmarks. It consistently outperformed previous state-of-the-art (SOTA) methods, including Transformer-based architectures like BTTR, notably achieving these results without the use of data augmentation or model ensembling.

Dataset ABM ExpRate (Accuracy) Previous SOTA (BTTR)
CROHME 2014 56.85% 53.96%
CROHME 2016 52.92% 52.31%
CROHME 2019 53.96% 52.96%

Beyond overall accuracy, the model demonstrated improved robustness in recognizing the final symbols of expressions (suffixes), where traditional L2R models typically degrade. For instance, accuracy on 2-symbol suffixes improved from 80.02% to 84.37% through mutual learning.

Conclusion

The ABM framework represents a significant step forward in HMER by effectively combining multi-scale spatial attention with bi-directional temporal context. By leveraging mutual learning during training and maintaining a streamlined single-decoder architecture for inference, ABM achieves superior performance across multiple benchmarks without increasing deployment costs. Future research may explore applying this "universal" mutual learning framework to other complex document recognition tasks.

Summary updated

BibTeX
@inproceedings{bian2022handwritten,
  author = {Xiaohang Bian and Bo Qin and Xiaozhe Xin and Jianwu Li and Xuefeng Su and Yanfeng Wang},
  title = {{Handwritten Mathematical Expression Recognition via Attention Aggregation Based Bi-directional Mutual Learning}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2022},
  doi = {10.1609/aaai.v36i1.19885},
}
Figure