Abstract
This paper introduces IM2LATEX-100K, a large-scale dataset for the task of translating images of mathematical expressions into LaTeX markup. The dataset contains approximately 100,000 formulas parsed from arXiv sources, provided as high-resolution PNG images with corresponding ground-truth LaTeX strings. Alongside the dataset, the authors propose a neural encoder-decoder model featuring a novel coarse-to-fine attention mechanism designed to handle the high-resolution, two-dimensional nature of mathematical notation efficiently.
Introduction
Traditional Optical Character Recognition (OCR) systems are primarily optimized for linear, one-dimensional text. Mathematical notation, however, is inherently non-linear, utilizing nested fractions, exponents, and subscripts that require spatial reasoning. While modern image-to-text models can address these structures using attention mechanisms, they face a significant computational bottleneck: standard attention complexity scales as $O(T \times H \times W)$, where $T$ is the output length and $H, W$ are image dimensions. For high-resolution equation images, this becomes prohibitively expensive. This work seeks to bridge the gap between structural awareness and computational efficiency.
Methodology
The proposed architecture consists of three primary components designed to capture the spatial nuances of math:
- Convolutional Neural Network (CNN): A multi-layer CNN extracts visual features from the input image.
- Row Encoder: To better localize relative positions in a 2D grid, the model passes CNN features through a Recurrent Neural Network (RNN) that processes each row. This step is crucial for maintaining spatial constraints.
- Coarse-to-Fine Attention: This is the core innovation. Instead of calculating attention weights for every cell in a fine-grained feature map, the model first attends to a "coarse" grid to identify a support region. It then performs fine-grained attention only within that specific region.
To train the non-differentiable "hard" selection of regions, the authors employed the REINFORCE algorithm, treating the choice of the coarse region as a stochastic action. They also explored sparsemax, a version of softmax that produces sparse probability distributions, as a differentiable alternative.
The IM2LATEX-100K Dataset
The authors contribute IM2LATEX-100K, a benchmark containing 103,556 unique LaTeX formulas extracted from arXiv papers. The dataset includes original LaTeX source code and rendered PNGs. Additionally, the researchers evaluated their model on the CROHME 2013 & 2014 datasets for handwritten mathematical expression recognition, using IM2LATEX-100K for pre-training to improve robustness across different styles.
Key Results
The experimental results demonstrate that the neural encoder-decoder approach significantly outperforms traditional methods. On the IM2LATEX-100K test set, the model achieved an exact match rate of 77.46%, compared to just 15.60% for the classical INFTY system and 7.60% for neural CTC-based models.
Key findings include:
- Efficiency Gains: The coarse-to-fine "hard" attention model reduced the number of fine-grained attention computations from 355 per token to just 16, while maintaining a high match rate of 74.90%.
- Spatial Awareness: Connectionist Temporal Classification (CTC) fails on math because it enforces strict linearity. General-purpose encoders with 2D attention are far superior at tracking the non-linear flow of equations.
- Handwriting Robustness: Despite being trained on rendered LaTeX, the model achieved competitive results on CROHME challenges after fine-tuning, proving its ability to generalize to handwritten inputs.
Discussion and Limitations
While highly effective, the model is "data hungry," requiring approximately 16,000 examples to reach 50% accuracy. Qualitative analysis shows that errors are often "presentation-affecting" rather than structural—such as failing to use the correct parenthesis size (\left( vs () or missing specific math font escapes (e.g., \mathcal). Future work may involve applying coarse-to-fine mechanisms to multi-page document layouts and integrating them with neural memory networks.
Summary updated