LayoutLMv2: Multi-modal Pre-training for Visually-rich Document Understanding

Yang Xu, Yiheng Xu, Tengchao Lv, Lei Cui, Furu Wei, Guoxin Wang, Yijuan Lu, Dinei A. F. Florêncio, Cha Zhang, Wanxiang Che, Min Zhang, Lidong Zhou

Introduction

Visually-rich Document Understanding (VrDU) is a critical task in automated information extraction, involving the processing of scanned or digital documents such as invoices, forms, and reports. Traditional NLP models often struggle with these documents because they prioritize word sequences while ignoring the "visual language" of the page—the spatial relationships between headers, tables, signatures, and logos.

While the original LayoutLM made strides by incorporating layout information, it often treated text and visual modalities as separate entities, fusing them only late in the process. LayoutLMv2 addresses this by introducing a unified multi-modal framework that learns deep interactions between text, layout, and image information during large-scale pre-training.

Architecture and Methodology

LayoutLMv2 utilizes a multi-modal Transformer encoder to process text, layout, and visual tokens simultaneously. This "deep fusion" approach allows the model to capture cross-modal correlations that are often missed by late-fusion architectures.

The LayoutLMv2 architecture integrates visual, text, and layout embeddings with spatial-aware self-attention and multi-modal pre-training objectives.

Technical Innovations

  • Integrated Visual Embedding: Visual features are incorporated directly into the pre-training stage. A ResNeXt-FPN backbone converts document images into visual tokens, which are then concatenated with text tokens.
  • Spatial-Aware Self-Attention: Beyond absolute coordinates, LayoutLMv2 integrates a relative position bias into its attention mechanism. This enables the model to explicitly understand the spatial distance and direction between tokens, making it robust to formatting variations.
  • Multi-modal Pre-training Objectives:
    • Masked Visual-Language Modeling (MVLM): Masks text tokens and covers corresponding image regions to prevent visual "cheating."
    • Text-Image Alignment (TIA): A fine-grained task where the model predicts if specific text lines in the image have been covered.
  • Text-Image Matching (TIM): A coarse-grained task predicting if an image and text sequence belong to the same document page.

Experimental Results

The model was pre-trained on the IIT-CDIP dataset, containing 11 million scanned document pages, and evaluated across several benchmarks including FUNSD (form understanding), CORD/SROIE (receipt extraction), and DocVQA (visual question answering).

LayoutLMv2 significantly outperforms previous state-of-the-art models across multiple document understanding benchmarks.

As shown in the results, LayoutLMv2 achieved dominant performance across the board:

  • FUNSD: Improved F1 score from 0.7895 to 0.8420.
  • DocVQA: Achieved a significant jump in ANLS (Average Normalized Levenshtein Similarity) from 0.7295 to 0.8672, surpassing even large ensembles of other models.
  • RVL-CDIP: Reached 95.64% accuracy in document classification, proving the benefits of multi-modal pre-training for high-level semantic understanding.

Conclusion

LayoutLMv2 demonstrates that integrating visual information as first-class tokens during pre-training is essential for robust document understanding. By combining deep fusion with spatial-aware attention, the model learns the underlying logic of document layouts rather than just memorizing fixed coordinates. Future work will focus on expanding the model to support multiple languages and optimizing its computational efficiency for real-world deployment.

Summary updated

BibTeX
@inproceedings{xu2021layoutlmv,
  author = {Yang Xu and Yiheng Xu and Tengchao Lv and Lei Cui and Furu Wei and Guoxin Wang and Yijuan Lu and Dinei A. F. Florêncio and Cha Zhang and Wanxiang Che and Min Zhang and Lidong Zhou},
  title = {{LayoutLMv2: Multi-modal Pre-training for Visually-rich Document Understanding}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.acl-long.201},
}
Figure