TL;DR
DocGraphLM is a novel framework that enhances Visually Rich Document Understanding (VrDU) by combining the semantic power of pre-trained language models with the structural strengths of Graph Neural Networks (GNNs). By reconstructing document graphs through a specialized link prediction task that prioritizes local neighborhoods, the model achieves state-of-the-art results in information extraction and question answering while significantly accelerating training convergence.
What Problem Does This Paper Address?
Understanding "visually rich documents" (VrDs)—like invoices, receipts, and complex forms—requires more than just reading text; it requires understanding layout. While Transformer-based models like LayoutLM have set high benchmarks by fusing text and spatial coordinates, they often struggle with spatially distant but semantically related elements, such as a table cell far from its header or content split across line breaks.
Conversely, Graph Neural Networks (GNNs) are excellent at modeling these structural relationships but typically lack the deep semantic understanding found in large-scale pre-trained language models (PLMs). DocGraphLM aims to bridge this gap, creating a hybrid architecture that captures both the "what" (semantics) and the "where" (structure) of document data more effectively.
Methods
The authors propose a joint encoder architecture that integrates a PLM with a GNN. The core innovation lies in how they represent and reconstruct the document graph:
- Graph Representation: Documents are treated as graphs where nodes are text segments. To define edges, they use a Direction Line-of-Sight (D-LoS) heuristic. Instead of just connecting the $K$-nearest neighbors, they divide the area around a node into eight 45-degree sectors and connect to the nearest node in each sector. This ensures a balanced structural representation in all directions.
- Node Features: Each node combines text embeddings from a language model with physical dimensions (width and height) to capture font size and semantic roles (e.g., distinguishing a title from body text).
- Link Prediction & Joint Loss: The model is trained to reconstruct the graph by predicting the distance and direction between nodes. They use a novel joint loss function:
- Distance: A regression task using Mean Squared Error (MSE) on log-transformed distances.
- Direction: A classification task using Cross-Entropy across the eight sectors.
- Weighting: Crucially, the loss function includes a weighting mechanism that prioritizes the restoration of nearby neighbors and down-weights distant nodes, treating elements beyond a certain distance as semantically equidistant.
- Joint Representation: The final document representation is a concatenation of the language model's output and the GNN's latent node/edge representations.
Datasets
The model was evaluated on three standard Visually Rich Document Understanding benchmarks:
- FUNSD: A dataset for form understanding in noisy scanned documents (4 labels).
- CORD: A consolidated receipt dataset for post-OCR parsing (30 labels).
- DocVQA: A large-scale dataset for visual question answering on document images. The authors noted some imperfect OCR in the original set and created a modified version, $DocVQA^\dagger$, for internal validation.
Key Insights and Ideas
- Structure as a Catalyst: The most striking finding is that adding graph features doesn't just improve accuracy—it accelerates learning. The model converges much faster because the graph structure allows the Transformer to focus more effectively on relevant local neighborhoods.
- Overcoming Transformer Limitations: By explicitly modeling spatial links, DocGraphLM compensates for the "flat" nature of standard Transformer attention, which can sometimes lose track of layout-dependent relationships in complex documents.
- Logarithmic Distance Smoothing: Using a log transformation for distance prediction helps the model ignore "noise" from very distant nodes while remaining highly sensitive to the precise positioning of immediate neighbors.
Key Results
DocGraphLM demonstrated consistent improvements across all tested datasets:
- FUNSD: Reached a top F1 score of 88.77, outperforming the previous state-of-the-art (LayoutLMv3-base) by 0.61 points.
- CORD: Achieved an F1 score of 96.93, a 1.62-point improvement over the baseline.
- DocVQA: The model scored 69.84 on the official leaderboard, showing superior performance in understanding forms and tables compared to pure language-layout models.
- Convergence: As shown in Figure 2, DocGraphLM reaches high F1 scores significantly earlier in the training process (within the first four epochs) compared to vanilla LayoutLM.
Limitations and Future Work
The authors acknowledge that the quality of the underlying OCR remains a bottleneck; imperfect text alignment or missing text in the source datasets can lead to failures in downstream tasks.
For future work, the team plans to:
- Incorporate different pre-training techniques tailored for specific document segments (e.g., specialized headers vs. body text).
- Examine the impact of different linkage representations beyond the D-LoS approach for graph reconstruction.
- Explore how these graph features might scale with even larger language models.
Summary updated