Skip to main content
QUICK REVIEW

[Paper Review] Image-to-Markup Generation with Coarse-to-Fine Attention

Yuntian Deng, Anssi Kanervisto|arXiv (Cornell University)|Sep 16, 2016
Mathematics, Computing, and Information ProcessingComputer Science85 citations
TL;DR

This paper proposes a coarse-to-fine attention mechanism in a neural encoder-decoder model for image-to-markup generation, specifically targeting image-to-LaTeX conversion. By using a multi-row recurrent encoder and a two-stage attention mechanism that first selects a support region and then applies fine-grained attention, the model reduces computational overhead while achieving 77.46% match accuracy on real-world rendered mathematical expressions, outperforming classical OCR systems and showing strong generalization to handwritten data with fine-tuning.

ABSTRACT

We present a neural encoder-decoder model to convert images into presentational markup based on a scalable coarse-to-fine attention mechanism. Our method is evaluated in the context of image-to-LaTeX generation, and we introduce a new dataset of real-world rendered mathematical expressions paired with LaTeX markup. We show that unlike neural OCR techniques using CTC-based models, attention-based approaches can tackle this non-standard OCR task. Our approach outperforms classical mathematical OCR systems by a large margin on in-domain rendered data, and, with pretraining, also performs well on out-of-domain handwritten data. To reduce the inference complexity associated with the attention-based approaches, we introduce a new coarse-to-fine attention layer that selects a support region before applying attention.

Motivation & Objective

  • To develop a data-driven neural model that generates structured markup (e.g., LaTeX) directly from images without relying on handcrafted grammars or layout rules.
  • To address the high computational cost of standard attention mechanisms in sequence generation by introducing a coarse-to-fine attention mechanism that reduces attention lookups.
  • To evaluate the model on a new, large-scale dataset of real-world rendered mathematical expressions paired with LaTeX markup.
  • To assess generalization to out-of-domain handwritten data through fine-tuning on synthetic handwritten data.
  • To demonstrate that attention-based models can outperform CTC-based OCR systems on non-standard, layout-sensitive OCR tasks like mathematical expression recognition.

Proposed method

  • The model uses a convolutional neural network (CNN) to encode the input image into feature maps, followed by a multi-row recurrent encoder to model vertical layout and spatial structure.
  • A coarse-to-fine attention mechanism is introduced: a coarse-level soft attention selects a support region (e.g., 4×4 grid), and a fine-level attention operates only within that region to reduce computation.
  • The coarse-level attention is trained using REINFORCE with a hard-attention variant or sparsemax to balance accuracy and efficiency.
  • The decoder is an autoregressive RNN that generates LaTeX tokens one at a time, conditioned on the image features and previous predictions.
  • The model is trained end-to-end using cross-entropy loss on a new dataset, Im2Latex-100k, consisting of 100k real-world rendered mathematical expressions with corresponding LaTeX markup.
  • A synthetic handwritten dataset is created for zero-shot generalization experiments, enabling fine-tuning on CROHME benchmark data.

Experimental results

Research questions

  • RQ1Can an end-to-end neural model generate accurate LaTeX markup from rendered mathematical expressions without relying on explicit layout grammars or segmentation?
  • RQ2Does a coarse-to-fine attention mechanism effectively reduce inference complexity while maintaining high accuracy in image-to-markup generation?
  • RQ3Can a model pre-trained on synthetic handwritten data generalize to real handwritten mathematical expressions, even with limited in-domain data?
  • RQ4How does the performance of attention-based models compare to CTC-based approaches on non-standard OCR tasks involving complex layout and structure?
  • RQ5What is the contribution of each component (e.g., multi-row encoder, positional embeddings, coarse-to-fine attention) to the final model performance?

Key findings

  • The proposed model achieves a 77.46% match accuracy on the Im2Latex-100k test set, significantly outperforming classical mathematical OCR systems on in-domain rendered data.
  • The coarse-to-fine attention mechanism reduces the average number of fine-grained attention lookups from 355 (standard attention) to 16 (hard attention), with only a 2.5% drop in accuracy.
  • The sparsemax variant of coarse-to-fine attention achieves 76.15% accuracy while using 74 fine lookups, offering a good trade-off between efficiency and performance.
  • The multi-row recurrent encoder contributes significantly to performance, improving accuracy over a single-row or non-recurrent encoder.
  • With only 16k training examples, the model reaches 50% accuracy, indicating strong data efficiency, though performance improves with larger datasets.
  • Fine-tuning on the CROHME 2013 and 2014 datasets after pretraining on synthetic handwritten data leads to performance comparable to top commercial systems, except MyScript, which has access to more in-domain data.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.