GVdoc - Graph-based Visual DOcument Classification

Fnu Mohbat, Mohammed J. Zaki, Catherine Finegan-Dollak, Ashish VermaACL 2023

Introduction

Document AI has seen significant advancements through the application of Transformer-based models like LayoutLM. However, these models typically treat document pages as 1D sequences of tokens. This serialization process is inherently fragile; it relies heavily on the "reading order" determined by Optical Character Recognition (OCR) engines. When the reading order is misidentified, the spatial context is lost, leading to performance degradation. Furthermore, large-scale Transformers are computationally expensive and often struggle with out-of-distribution (OOD) data—documents that differ from the training set in layout or origin.

To address these challenges, we present GVdoc, a graph-based approach to document classification. GVdoc prioritizes the two-dimensional structural layout of documents by representing them as sparse graphs. By utilizing Graph Attention Networks (GATs), GVdoc achieves superior robustness and efficiency compared to traditional sequence-based models.

Methodology

GVdoc shifts the paradigm from "text-as-a-sequence" to "text-as-a-graph." This approach preserves the geometric relationships between document elements without requiring a fixed 1D order.

Graph Construction

The document is represented as a graph where each word (token) serves as a node. Edges are established using two complementary strategies:

  1. β-skeleton Graph: This spatial method connects nodes based on proximity using a "ball-of-sight" algorithm. It ensures the model captures the physical layout and local geometric context.
  2. Paragraph-based Neighborhood: This strategy connects tokens within the same paragraph and links adjacent paragraphs based on the predicted reading order, providing a hierarchical structural prior.

Architecture and Feature Fusion

GVdoc employs a Graph Attention Network (GAT) to learn node and graph-level embeddings. Unlike fully connected Transformers, the GAT passes messages only along the defined edges, significantly reducing computational overhead. To integrate multi-modal information, a cross-attention module fuses text embeddings (initialized from BERT) with layout embeddings, which incorporate both token-level and paragraph-level bounding box coordinates.

Pre-training Objectives

The model undergoes pre-training on the IITCDIP dataset using three specialized tasks designed to align text and position:

  • Masked Language Modeling (MLM): Predicting masked tokens based on context.
  • Masked Position Modeling (MPM): Predicting the coordinates of masked bounding boxes.
  • Cell Position Prediction (CPP): Learning the relative positioning of document elements.

Experimental Evaluation

The performance of GVdoc was evaluated using the RVLCDIP benchmark, which consists of 400,000 images across 16 categories. To test robustness, the authors utilized three distinct test sets:

  • RT (RVLCDIP Test): Standard in-distribution data.
  • RN (RVLCDIP-N): Out-of-distribution but in-domain data (same categories, different sources).
  • RO (RVLCDIP-O): Out-of-distribution and out-of-domain data (entirely unseen categories used for detection).

Results and Key Insights

1. Superior OOD Robustness One of the most striking findings is GVdoc's performance on the RN dataset. While LayoutLMv2—a model with nearly six times the parameters—saw its accuracy drop to 55.6% when using open-source OCR, GVdoc maintained a micro-accuracy of 89.90%. GVdoc demonstrated remarkable stability, showing a slight improvement (+2.3%) between in-distribution and OOD data, whereas other models experienced gaps as large as 33%.

2. Computational Efficiency GVdoc achieves state-of-the-art results with only 34 million parameters. In comparison, LayoutLMv2 utilizes 200 million parameters. This efficiency suggests that incorporating structural priors through graph representations is more effective for document understanding than simply increasing model scale.

3. Effective OOD Detection GVdoc excels at identifying "unknown" document types. Using energy-based scores on the RO dataset, the model achieved an AUC of 0.997. This significantly outperforms traditional architectures like DiT (0.753) and VGG-16 (0.648), making GVdoc highly suitable for real-world applications where identifying novel document classes is critical.

Conclusion

GVdoc demonstrates that graph-based representations offer a robust and efficient alternative to sequence-based Transformers for document classification. By leveraging the geometric structure of documents, the model overcomes the limitations of 1D serialization and exhibits exceptional generalization to out-of-distribution data.

Future work will focus on reducing the dependence on OCR engines, as errors in initial detection can propagate through the graph. Additionally, the authors plan to integrate visual features—such as font styles, logos, and embedded images—and explore the impact of extended pre-training cycles to further enhance performance.

Summary updated

BibTeX
@inproceedings{mohbat2023gvdoc,
  author = {Fnu Mohbat and Mohammed J. Zaki and Catherine Finegan-Dollak and Ashish Verma},
  title = {{GVdoc - Graph-based Visual DOcument Classification}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.findings-acl.329},
}
Figure