In the world of Document Intelligence, the current "gold standard" often involves throwing massive, pre-trained transformer models (like LayoutLM) at the problem. While these models are powerful, they are computationally expensive, hungry for data, and often act as "black boxes" regarding the document's underlying structure.
A new paper titled "Doc2Graph: a Task Agnostic Document Understanding Framework based on Graph Neural Networks" proposes a different path. Instead of relying on brute-force pre-training, the authors suggest that we should treat documents as what they fundamentally are: a collection of entities with specific spatial and semantic relationships.
TL;DR
Doc2Graph is a lightweight, GNN-based framework that solves multiple document understanding tasks—like entity linking and table detection—without requiring massive pre-training. By representing documents as fully connected graphs and using polar coordinates to encode relative positions, it achieves competitive results with a fraction of the parameters used by state-of-the-art transformers.
What Problem Does This Paper Address?
Most document analysis tools are specialized: one model finds tables, another extracts key-value pairs from forms. Furthermore, the industry has pivoted toward "Vision-Language" models that require hundreds of millions of parameters and immense datasets to learn that a "Total" label usually sits next to a currency value.
The authors identify two main gaps:
- Task Specificity: The need for a single framework that can handle diverse tasks (Key Information Extraction, Layout Analysis, Table Detection) across different document types.
- Fragile Heuristics: Existing graph-based methods often rely on "visibility graphs" or "k-nearest neighbors" to decide which words should be connected. If these manual rules fail, the model can't see the relationship.
Methods
The core innovation of Doc2Graph is its task-agnostic graph representation.
- Graph Construction: Unlike previous methods that use heuristics to draw edges, Doc2Graph starts with a fully connected graph. It lets the network itself learn which connections are relevant.
- Multi-modal Features: Each node (representing a word or entity) is assigned features from three sources:
- Textual: Word embeddings via spaCy.
- Visual: Features extracted from a U-Net backbone using RoI (Region of Interest) Align.
- Geometrical: Absolute normalized positions on the page.
- The Secret Sauce: Polar Coordinates: To help the model understand relative layout, edges are encoded using polar coordinates (distance and discretized angle bins). This allows the model to understand that "Node A is 20 pixels to the right of Node B" in a way that is robust to different document scales and orientations.
- Architecture: The framework uses a modified version of GraphSAGE. Crucially, they introduce a distance threshold in the aggregation function to maintain "locality"—ensuring that a node's representation is primarily influenced by its immediate neighbors.
Datasets
The authors evaluated Doc2Graph on two primary benchmarks:
- FUNSD (Revised): A dataset of 199 scanned forms. The authors used a revised version to correct labeling inconsistencies that often plague the original set.
- RVL-CDIP Invoices: A subset of 518 annotated invoices used for testing layout analysis (categorizing regions like "supplier" or "receiver") and table detection.
Key Insights and Ideas
- Geometry is King: Ablation studies revealed that combining geometrical and textual features provides the biggest performance boost. Interestingly, while visual features (style/formatting) help, they significantly increase the parameter count for relatively modest gains.
- Learning Connectivity beats Hard-coding: By starting with a fully connected graph and using a distance-weighted GNN, the model avoids the "missing edge" problem common in visibility graphs.
- Efficiency Matters: Doc2Graph achieves its results with roughly 13.5 million parameters. For context, many transformer-based competitors use 10x to 30x more parameters, making Doc2Graph a viable candidate for edge computing or applications with limited hardware.
Key Results
- Entity Linking (FUNSD): When provided with ground-truth entities, the model achieved an F1 score of 0.5336, outperforming several GNN baselines.
- Layout Analysis (Invoices): The model achieved 67.8% accuracy, significantly outperforming the previous state-of-the-art graph method (62.3%).
- Table Detection: The framework proved it could successfully extract tables by treating them as subgraphs where nodes are linked by a "table" edge, achieving an F1 of 0.3754, which is a notable improvement over prior binary classification approaches on the same data.
Limitations and Future Work
The authors are transparent about where the model struggles:
- One-to-Many Relationships: The model currently finds it difficult to generalize complex relationships, such as a single header cell that applies to multiple rows or columns.
- Data Scarcity: GNNs are sensitive to the amount of training data. The small size of the FUNSD and RVL-CDIP subsets limits the model's ability to generalize to wildly different layouts.
- Future Directions: The team plans to integrate more explicit table structure recognition and explore how to better combine multi-modal features without ballooning the parameter count.
In summary, Doc2Graph makes a compelling case for "structural intelligence" over "brute-force pre-training," offering a path toward more efficient and interpretable document understanding.
Summary updated