Abstract
Structured Document Understanding (SDU) requires models to interpret both textual content and visual layout. Current state-of-the-art approaches often rely on millions of parameters to learn layout embeddings from Cartesian coordinates. This paper introduces LAGaBi (Layout Attention with Gaussian Biases), a lightweight, model-agnostic mechanism that replaces absolute position embeddings with relative attention biases. By utilizing polar coordinates and 2D Gaussian kernels, LAGaBi injects a human-like spatial inductive bias into the Transformer architecture. This approach reduces layout-related parameters to as few as 48 while significantly improving performance across multiple SDU benchmarks, including FUNSD and CORD.
Introduction
Extracting information from structured documents like forms, receipts, and invoices is a core challenge in document AI. While models like LayoutLM have successfully integrated layout information, they typically do so via absolute Cartesian ($x, y$) embeddings. This approach suffers from two primary drawbacks: significant parameter bloat and a coordinate system that does not naturally reflect the relative spatial relationships—distance and angle—that humans use to navigate a page.
LAGaBi addresses these inefficiencies by asking whether a more intuitive coordinate system and a targeted inductive bias can model layout more effectively and efficiently.
Methodology: Layout Attention with Gaussian Biases
LAGaBi moves away from absolute position embeddings at the input layer, instead injecting layout information directly into the self-attention mechanism as a bias term.
Polar Coordinates and Gaussian Kernels
Rather than using $x$ and $y$ offsets, LAGaBi calculates the relative distance ($\rho$) and angle ($\theta$) between every pair of tokens. This polar representation is more robust to document scaling than absolute Cartesian coordinates. These coordinates are then passed through a 2D Gaussian kernel to generate attention scores. This enforces a natural inductive bias: tokens that are spatially closer or aligned at specific angles should naturally receive more mutual attention.
Extreme Parameter Efficiency
The Gaussian kernel requires learning only a mean and variance for each attention head. For a standard RoBERTa-base model with 12 heads, this totals just 48 parameters. This is a staggering reduction compared to the millions of parameters typically required for traditional layout embeddings, making LAGaBi exceptionally lightweight and easy to integrate into existing architectures.
Experimental Results
The researchers evaluated LAGaBi across several standard SDU benchmarks, including FUNSD (form understanding), CORD (receipt extraction), and XFUND (multilingual form understanding).
Performance Gains
The integration of LAGaBi consistently improved performance across various base models. For "vanilla" models like RoBERTa, which have no native layout awareness, adding LAGaBi improved the F1 score on the FUNSD dataset by 18.38% and on CORD by 2.43% without any document-specific pre-training. When combined with state-of-the-art models like LayoutLMv3, LAGaBi pushed performance even further, achieving a new SOTA F1 score of 91.00% on FUNSD.
Key Insights
- Angle vs. Distance: Ablation studies showed that encoding the angle between words is more effective than encoding Euclidean distance alone, likely because angles are invariant to document zooming.
- Model Agnosticism: LAGaBi proved to be a versatile module, successfully enhancing BERT, RoBERTa, and LayoutLMv3.
- Universal Spatial Language: On the multilingual XFUND benchmark, LAGaBi outperformed specialized models like LiLT, suggesting that spatial relationships serve as a "universal language" across different scripts.
Conclusion and Future Work
LAGaBi demonstrates that a well-placed inductive bias can outperform brute-force parameterization. By using just 48 parameters to model spatial relationships, it achieves state-of-the-art results while remaining highly efficient.
Future work may involve integrating LAGaBi during the initial heavy pre-training phase of multi-modal models to further unlock its potential. Additionally, while the Gaussian distribution is intuitively effective, further research could explore whether other mathematical distributions might offer even better alignment with document layout structures.
Summary updated