Abstract
We propose SelfDoc, a task-agnostic pre-training framework for document image understanding. Because documents are multimodal and are intended for sequential reading, our framework exploits the positional, textual, and visual information of every semantically meaningful component in a document, and it models the contextualization between each block of content. Unlike existing document pre-training models, our model is coarse-grained instead of treating individual words as input, therefore avoiding an overly fine-grained with excessive contextualization. Beyond that, we introduce cross-modal learning in the model pre-training phase to fully leverage multimodal information from unlabeled documents. For downstream usage, we propose a novel modality-adaptive attention mechanism for multimodal feature fusion by adaptively emphasizing language and vision signals. Our framework benefits from self-supervised pre-training on documents without requiring annotations by a feature masking training strategy. It achieves superior performance on multiple downstream tasks with significantly fewer document images used in the pre-training stage compared to previous works.
Introduction
Automated document understanding—the ability to parse invoices, forms, or research papers—is a complex multimodal challenge. To truly "understand" a page, a system must integrate textual content, visual appearance (fonts, styles), and positional layout. Traditional state-of-the-art models, such as LayoutLM, typically operate at the word level. However, this fine-grained approach can lead to massive computational overhead and "excessive contextualization," where the model loses sight of the broader semantic purpose of a block of text.
SelfDoc addresses these issues by shifting the focus from individual words to "semantically meaningful components" like text blocks, headings, and figures. By modeling the interplay between modalities at this coarser grain, SelfDoc achieves superior performance while requiring significantly less pre-training data.
Methodology
The SelfDoc framework introduces three major innovations to the standard Transformer-based document pipeline: component-level modeling, a cross-modality encoder, and modality-adaptive attention.
Component-Level Modeling
Instead of treating every word as an input token, SelfDoc uses an object detector (e.g., Faster R-CNN) to identify high-level components such as titles, lists, tables, and text blocks. These components become the primary units of information, allowing the model to capture the intent of a document region more naturally.
Cross-Modality Encoder
During pre-training, the model employs a specialized encoder with interactive cross-attention. This allows textual features to interact directly with visual features within the same component. This cross-modal learning helps the model identify agreements—for example, confirming that a block labeled as a "Heading" visually appears in a large, bold font.
Modality-Adaptive Attention (M-AA)
During fine-tuning, SelfDoc uses a novel fusion mechanism called Modality-Adaptive Attention. Rather than a static combination of features, M-AA learns to weight textual and visual signals dynamically. If a document is a clean digital article, the model may prioritize text; if it is a noisy, handwritten form where OCR might fail, it shifts its attention to visual cues.
Experimental Evaluation
SelfDoc was pre-trained using a self-supervised "feature masking" strategy on 320,000 unlabeled documents from the RVL-CDIP dataset. Despite using roughly 34 times less data than models like LayoutLM (which uses 11 million images), SelfDoc achieved state-of-the-art results:
- Entity Recognition (FUNSD): Achieved an F1 score of 0.8336, significantly higher than LayoutLM’s 0.7927.
- Document Classification: Reached 93.81% accuracy on the RVL-CDIP benchmark.
- Unsupervised Clustering: Showed massive improvements in Accuracy and Normalized Mutual Information (NMI) over standard BERT and LayoutLM baselines.
Discussion and Conclusion
SelfDoc demonstrates that modeling documents at the component level is a more efficient and effective strategy for representation learning than word-level modeling. By capturing the "forest" rather than just the "trees," the model naturally understands document logic and layout. While the system is currently dependent on the accuracy of initial object detection and OCR, its robustness and data efficiency mark a significant step forward in multimodal document understanding. Future work may extend this approach to multi-page reasoning, where relationships between blocks across pages become critical.
Summary updated