A Hybrid Vision Transformer Approach for Mathematical Expression Recognition
Authors: Anh Duy Le, Van Linh Pham, Vinh Loi Ly, Nam Quan Nguyen, Huu Thang Nguyen, Tuan Anh Tran
Organizations: Viettel Cyberspace Center, Viettel Group, Vietnam. Lot D26 Cau Giay New Urban Area, Yen Hoa Ward, Cau Giay District, Hanoi, Vietnam. · Faculty of Computer Science & Engineering, Ho Chi Minh City-University of Technology (HCMUT), 268 Ly Thuong Kiet Street, District 10, Ho Chi Minh City, Vietnam. · Vietnam National University Ho Chi Minh City, Linh Trung Ward, Thu Duc District, Ho Chi Minh City, Vietnam.
One of the crucial challenges taken in document analysis is mathematical expression recognition. Unlike text recognition which only focuses on one-dimensional structure images, mathematical expression recognition is a much more complicated problem because of its two-dimensional structure and different symbol size. In this paper, we propose using a Hybrid Vision Transformer (HVT) with 2D positional encoding as the encoder to extract the complex relationship between symbols from the image. A coverage attention decoder is used to better track attention's history to handle the under-parsing and over-parsing problems. We also showed the benefit of using the [CLS] token of ViT as the initial embedding of the decoder. Experiments performed on the IM2LATEX-100K dataset have shown the effectiveness of our method by achieving a BLEU score of 89.94 and outperforming current state-of-the-art methods.
Figures & tables
Fig. 1: A general overview of our proposed framework
Fig. 2: The proposed architecture pipeline and illustration of ViT block.
Acc
BLEU-4
TED
params
Component
Experiment
%
%
%
×106
Feat.
Baseline
22.15
79.12
77.32
7.05
V1
37.55
85.90
89.90
45.76
Context.
Baseline
22.15
79.12
77.32
7.05
V2
34.97
87.73
92.23
12.13
V3
43.69
90.61
94.52
9.75
TABLE III: Ablation experiments on different key components of our approach evaluate on IM2LATEX-100K validation set. Particularly, Feat. denote feature extraction, Context. denote context modeling, and Pred. denote prediction.
Positional Encoding
Acc
BLEU-4
IED
EMA (w/o space)
1D
45.78
88.84
89.31
82.93
2D
48.39
89.94
92.23
86.48
TABLE IV: Comparison between two positional encoding method when apply to our proposed method.
Use init
Acc
BLEU-4
IED
EMA (w/o space)
✓
48.39
89.94
92.23
86.48
✗
43.87
81.73
89.36
81.02
TABLE V: Comparison on two initial hidden state settings when apply to our proposed method.
Fig. 3: Comparison between our proposed method and the baseline model at different sequence length.
Fig. 4: Examples of self-attention map of [CLS] token embedding.
Fig. 5: Visualization of a step-by-step decoding process using our method on example math expression image.