Introduction
When humans read a document, they instinctively follow a logical sequence based on visual cues and layout structure. However, most Optical Character Recognition (OCR) engines lack this intuition, typically sorting text lines using simple "top-to-bottom, left-to-right" heuristics. This approach fails significantly on complex layouts, such as multi-column research papers or intricate tables, where it often "zippers" text from adjacent columns into a nonsensical stream.
Reading Order Detection (ROD) is the task of determining the correct sequence of text segments in a document. Despite its importance for downstream tasks like document summarization and translation, ROD has lagged behind other document AI fields due to the lack of large-scale, annotated datasets. LayoutReader addresses this gap by introducing a massive new benchmark and a layout-aware model architecture.
ReadingBank: A Large-Scale Dataset
The primary bottleneck for ROD research has been the labor-intensive nature of human annotation. The authors overcame this by creating ReadingBank, a dataset of 500,000 document images.
To generate ground-truth reading orders automatically, the researchers leveraged the internal XML metadata of Microsoft Word (.docx) files, which stores the logical sequence of text. They developed a "coloring scheme" to align this sequence with spatial coordinates: each word was assigned a unique ID mapped to an RGB color, and the document was rendered as a PDF using these colors. By analyzing the rendered colors, they could precisely map every word to its 2D bounding box and its position in the reading sequence.
The LayoutReader Model
LayoutReader is built on a sequence-to-sequence (seq2seq) architecture designed to integrate both textual content and spatial layout.
- Encoder: The model uses LayoutLM as its encoder. LayoutLM is pre-trained to understand the relationship between text and its 2D position (bounding boxes), making it ideal for capturing the structural cues necessary for ROD.
- Decoder: Unlike standard seq2seq models that generate text, the LayoutReader decoder predicts the indices of the source tokens in their correct reading order.
- Attention Mechanism: The model employs specific self-attention masks that allow it to consider the entire document layout simultaneously while generating the ordered sequence.
Key Insights and Results
A critical finding of this research is that layout information is more important than text content for determining reading order. In ablation studies, a version of the model using only layout information (bounding boxes) performed nearly as well as the full model, whereas a text-only version struggled. This suggests that the visual structure of a document is the primary signal for sequence detection.
The model also demonstrates remarkable robustness. Even when input tokens are completely shuffled—removing any implicit "top-to-bottom" bias—LayoutReader can reconstruct the correct sequence using spatial cues alone.
Performance Metrics
LayoutReader was evaluated using BLEU scores (measuring sequence similarity) and Average Relative Distance (ARD).
- Accuracy: LayoutReader achieved a page-level BLEU score of 0.9819, vastly outperforming the heuristic baseline of 0.6972.
- OCR Enhancement: The model can serve as a post-processing step for existing OCR tools. It improved the BLEU score of Tesseract OCR from 0.75 to 0.93 and boosted a high-end commercial OCR from 0.85 to 0.94.
- Error Reduction: The ARD, which measures the distance of tokens from their correct positions, dropped from 8.46 (heuristic) to 1.75.
Conclusion and Future Work
LayoutReader represents a significant step forward in document understanding by formalizing and solving the Reading Order Detection problem at scale. By moving beyond simple heuristics, it enables more accurate parsing of complex real-world documents. Future research will focus on expanding language support beyond English and improving robustness to the noise and distortions found in physical document scans.
Summary updated