ERNIE-Layout: Layout Knowledge Enhanced Pre-training for Visually-rich Document Understanding

Qiming Peng, Yinxu Pan, Wenjin Wang, Bin Luo, Zhenyu Zhang, Zhengjie Huang, Teng Hu, Weichong Yin, Yongfeng Chen, Yin Zhang, Shikun Feng, Yu Sun, Hao Tian, Hua Wu, Haifeng Wang · DOI

Abstract

ERNIE-Layout is a multi-modal pre-training framework designed to treat document layout as a primary modality. By incorporating human-like reading order serialization and a spatial-aware disentangled attention mechanism, the model achieves state-of-the-art performance in information extraction, document question answering, and image classification. This approach addresses the limitations of naive serialization and weak layout integration found in previous models.

Introduction

Visually-rich Document Understanding (VrDU) involves extracting data from complex documents like invoices, forms, and multi-column reports. While previous models successfully combined text and vision, they suffered from two major flaws. First, naive serialization based on raw OCR results (top-to-bottom, left-to-right) often breaks the logical flow of multi-column layouts or tables, scattering related words across the input sequence. Second, weak layout integration typically treats layout information as a simple 2D coordinate extension of 1D positions, lacking the sophisticated cross-modal interaction needed to understand how spatial structure influences meaning. ERNIE-Layout proposes a layout-knowledge enhanced workflow to overcome these challenges.

Methods

ERNIE-Layout introduces a comprehensive workflow that spans from data preprocessing to the core transformer architecture.

Smart Serialization

Instead of raster-scanning, ERNIE-Layout uses a Serialization Module powered by an advanced document parser. This module detects structural elements (paragraphs, tables, figures) to rearrange tokens into a proper logical reading order. As shown in the paper, this significantly reduces the perplexity (PPL) of the input sequence, making it easier for the model to learn semantic relationships.

The effect of layout-enhanced serialization vs. vanilla raster-scanning.

Spatial-aware Disentangled Attention

Inspired by DeBERTa, the model uses a modified attention mechanism. Instead of a single attention score, it computes four "disentangled" scores that account for Content-to-Content, Content-to-Position, and Position-to-Content relationships. By decoupling spatial features from content features in the attention matrix, the model can better generalize across different document styles without the spatial features "overwhelming" the semantic ones.

Novel Pre-training Tasks

Beyond standard masked language modeling, ERNIE-Layout introduces two key tasks to enhance multi-modal understanding:

  • Reading Order Prediction (ROP): The model predicts the next token in the sequence to ensure it understands the logical flow of the document. This task helps the model learn the human-like reading habits encoded during serialization.
  • Replaced Region Prediction (RRP): The model identifies which image patches have been randomly replaced with patches from other documents, forcing it to learn fine-grained correspondences between text, layout, and vision.
Overview of the ERNIE-Layout architecture and pre-training objectives.

Experimental Results

The model was pre-trained on 10 million document pages sampled from the IIT-CDIP collection. Evaluation was conducted on several industry-standard benchmarks, where ERNIE-Layout set new SOTA benchmarks across almost all tested datasets:

  • Key Information Extraction (KIE): On the FUNSD dataset, it achieved an F1 score of 0.9312, a significant jump over LayoutLMv2 (0.8420). It also showed strong performance on CORD, SROIE, and Kleister-NDA.
  • Document Question Answering: On DocVQA, it reached the top of the leaderboard with an ANLS score of 0.8841 (ensemble), demonstrating superior reasoning over document content.
  • Efficiency: Ablation studies showed that the Reading Order Prediction (ROP) task alone improved F1 scores by over 1.3% on the FUNSD dataset, proving that logical flow is critical for understanding complex forms.

Conclusion

ERNIE-Layout demonstrates that layout is a distinct and vital modality. By prioritizing logical reading order and spatial awareness, the model significantly advances the state of the art in VrDU. While the model's performance is highly effective, future work may address dependencies on underlying document parsers and the high computational cost of training large-scale transformer layers. The authors suggest further exploring how to integrate even more complex structural knowledge, such as hierarchical relationships in very long documents.

Summary updated

BibTeX
@inproceedings{peng2022ernie,
  author = {Qiming Peng and Yinxu Pan and Wenjin Wang and Bin Luo and Zhenyu Zhang and Zhengjie Huang and Teng Hu and Weichong Yin and Yongfeng Chen and Yin Zhang and Shikun Feng and Yu Sun and Hao Tian and Hua Wu and Haifeng Wang},
  title = {{ERNIE-Layout: Layout Knowledge Enhanced Pre-training for Visually-rich Document Understanding}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  doi = {10.18653/v1/2022.findings-emnlp.274},
}
Figure