Abstract
Automating the digitization of forms remains a significant challenge due to their dense, hierarchical nature. Form2Seq is a novel framework that treats form structure extraction as a sequence-to-sequence (Seq2Seq) task rather than a traditional image segmentation problem. By leveraging the natural reading order of text and spatial coordinates, it effectively classifies low-level elements and groups them into complex, higher-order structures like choice groups and text fields. Experimental results demonstrate that Form2Seq significantly out-performs pixel-based computer vision baselines, achieving high accuracy in both element classification and structural grouping.
Introduction
Converting static PDFs or scanned images into dynamic, re-flowable structures is a massive challenge in document AI. Standard deep learning approaches, such as Fully Convolutional Networks, often struggle with forms due to resolution limits—where downsampling causes closely spaced widgets to merge—and a lack of inherent hierarchy. Functional forms require more than just bounding boxes; they require logical ties between labels and widgets (e.g., "First Name" linked to a specific field) or the grouping of checkboxes into a single "Choice Group."
Form2Seq addresses these challenges by moving from pixels to sequences, utilizing the semantic meaning of text and the relative spatial arrangement of elements to bridge the gap between visual layout and logical structure.
Methodology
Form2Seq follows a bottom-up approach centered on linearization and a cascaded multi-module architecture:
- Linearization: Low-level elements (TextBlocks and Widgets) are arranged in a linear sequence based on natural reading order (top-to-bottom, left-to-right).
- Multi-Module Architecture:
- Text Encoder: Uses
chars2vecand an LSTM to create vector representations of text, providing robustness against OCR noise.
- Text Encoder: Uses
- Context Encoder: A Bidirectional LSTM (BiLSTM) processes the element sequence, combining text embeddings with spatial coordinates ($x, y, w, h$).
- Type Decoder: An LSTM with an attention mechanism predicts the category of each element (e.g., "Header," "TextField Caption").
- Cascaded Grouping: For higher-order tasks, the framework uses a cascaded model where the output from the Type Decoder informs a Group Context Encoder. This allows the model to use the predicted type of an element as a semantic hint to determine its group membership.
Results and Discussion
The framework was evaluated on a large-scale dataset of 23,000 forms and the ICDAR 2013 table recognition benchmark. Key findings include:
- Classification Superiority: Form2Seq achieved 90.06% accuracy in classifying low-level elements, outperforming state-of-the-art image segmentation models like DeepLabV3+.
- Structural Grouping: On the difficult task of identifying "Choice Groups," Form2Seq reached an F1-score of 59.72, nearly doubling the performance of the best image-based baseline (44.14).
- Versatility: The model achieved state-of-the-art results on table recognition (ICDAR 2013) with an average F1-score of 94.7, proving its utility for various structured document tasks.
These results highlight that text is a stronger signal than pixels in dense forms. By treating elements as discrete entities in a sequence, Form2Seq maintains robustness in dense layouts where image-based models typically fail.
Conclusion
Form2Seq represents a shift in form processing by prioritizing sequential and semantic context over raw pixel data. While the model currently assumes pre-extracted low-level elements, it sets a new benchmark for higher-order structure extraction. Future work will focus on integrating OCR and element detection directly into the Seq2Seq pipeline for a fully end-to-end system.
Summary updated