Introduction
Converting images of mathematical equations into structured markup like LaTeX is a significant challenge in optical character recognition (OCR). Unlike standard text, mathematical expressions involve complex 2D spatial layouts, including superscripts, subscripts, and fractions, alongside visually similar symbols (e.g., 'a' vs. '$\alpha$').
Traditional approaches utilize encoder-decoder models with attention mechanisms, typically relying on Recurrent Neural Networks (RNNs) or Long Short-Term Memory (LSTM) units for the decoder. However, these recurrent models process sequences sequentially, creating a computational bottleneck. Furthermore, they often suffer from "coverage" issues, leading to under-parsing (skipping symbols) or over-parsing (repeating symbols). ConvMath addresses these challenges by introducing an end-to-end, fully convolutional architecture that enables parallelization and improved alignment.
Methodology
ConvMath replaces traditional recurrent components with a fully convolutional structure, optimizing both training and inference speed.
Architecture Overview
The ConvMath architecture featuring a convolutional encoder-decoder structure with multi-layer attention. ConvMath: A Convolutional Sequence Network for Mathematical Expression Recognition, page 3
- Image Encoder (Modified ResNet): The model uses a deep CNN with residual connections to extract visual features. Residual connections are vital here; they preserve low-level details necessary for identifying tiny symbols while capturing high-level structural context.
- Convolutional Decoder: The decoder utilizes 1D convolutions and Gated Linear Units (GLUs) instead of LSTMs. This design allows the model to generate sequence computations in parallel across all time steps.
- Multi-Layer Attention: Attention is applied at every layer of the decoder. By feeding the sum of the current content vector and the previous layer's output into the next layer, the model implicitly tracks alignment history. This "implicit memory" mitigates the coverage problem without the need for computationally expensive explicit coverage vectors.
Experimental Setup and Datasets
The model was evaluated using the IM2LATEX-100K dataset, which contains 103,556 LaTeX expressions rendered into PNG images. The dataset is partitioned into 65,995 training, 8,181 validation, and 8,301 test samples, providing a robust benchmark for mathematical expression recognition.
Key Results
ConvMath demonstrates superior performance in both accuracy and computational efficiency compared to established baselines like WYGIWYS and WAP.
- Accuracy: ConvMath achieved a state-of-the-art BLEU score of 88.33 and an exact match accuracy of 83.41%.
- Efficiency: Due to its parallelizable architecture, ConvMath achieved an inference speed of 0.083 seconds per batch (batch size 10). This represents a 1.5x speedup over the LSTM-based WYGIWYS (0.129s) and WAP (0.135s) models.
- Ablation Insights: Results indicate that while the CNN decoder provides the speedup, the combination of the ResNet encoder and multi-layer attention is essential to surpass the accuracy of traditional recurrent models.
Conclusion and Future Work
ConvMath proves that sequence generation for complex OCR tasks does not strictly require recurrence. A fully convolutional architecture can capture sequential dependencies effectively while unlocking significant speed gains. While the multi-layer attention mechanism largely resolves over-parsing, some under-parsing persists in extremely complex expressions. Future research will focus on applying ConvMath to handwritten datasets and other 2D-to-1D translation tasks, such as musical score recognition and image captioning.
Summary updated