Reading Order Matters: Information Extraction from Visually-rich Documents by Token Path Prediction

Chong Zhang, Ya Guo, Yi Tu, Huan Chen, Jinyang Tang, Huijia Zhu, Qi Zhang, Tao Gui

Abstract

Traditional information extraction from visually-rich documents (VrDs) relies on sequential reading order, which is frequently disrupted by OCR errors in complex layouts. We present Token Path Prediction (TPP), a novel framework that models document entities as directed paths in a graph rather than linear sequences. By predicting links between tokens independently of their input position, TPP achieves significant robustness to disordered text. Experiments on revised benchmarks FUNSD-r and CORD-r demonstrate substantial performance gains, including a +9.13 F1 improvement on disordered layouts.

The Challenge of Disordered OCR

When extracting information from visually-rich documents (VrDs) like invoices, forms, or receipts, the standard approach is to treat it as a Named Entity Recognition (NER) task. Most models employ BIO (Beginning, Inside, Outside) tagging, which assumes that the words forming an entity appear in a continuous, front-to-back sequence in the model's input.

However, real-world OCR engines often recognize text in a strict "top-to-bottom, left-to-right" order that fails to capture the logical flow of complex layouts. In multi-column documents, an OCR might read all headers across the top before reading the corresponding content below. This "reading order issue" fundamentally breaks BIO tagging because the tokens belonging to a single entity may be scattered across the input sequence, making it impossible for a sequential model to label them correctly.

Figure 3: Standard BIO tagging fails when OCR scrambles the logical reading order, as the 'Inside' tags no longer follow the 'Beginning' tag sequentially.

Methods: Token Path Prediction (TPP)

To address this, the authors propose Token Path Prediction (TPP). Instead of classifying individual tokens in a sequence, TPP models the document as a complete directed graph where every token is a node.

Entity as a Path

In TPP, an entity is defined as a "token path"—a sequence of directed edges (e.g., Word A → Word B → Word C). For each entity type, the model predicts an $n \times n$ binary grid (where $n$ is the number of tokens). A "1" at position $(i, j)$ indicates a directed link from token $i$ to token $j$.

Figure 5: TPP maintains logical links between tokens regardless of their position in the input sequence, making it inherently robust to shuffling.

The Global Pointer Mechanism

The system utilizes a Global Pointer mechanism to predict these links, making it compatible with standard document transformers like LayoutLMv3. During inference, the model searches for paths within the predicted grid. Because it identifies links between tokens based on their relationship rather than their sequence position, the model is inherently resistant to disordered OCR results.

Benchmarking on Realistic Data

The authors argue that existing benchmarks like FUNSD and CORD are "too clean" because their reading orders were manually corrected during annotation. To test TPP in real-world conditions, they introduced FUNSD-r and CORD-r. These revised datasets use raw OCR outputs (from PP-OCRv3) to generate realistic, disordered layouts, re-annotating entities as word sequences to reflect actual extraction challenges.

Key Results and Insights

  • Order as an Output: The most significant shift in TPP is treating logical order as something the model discovers through path prediction, rather than a prerequisite for labeling.
  • Superior Performance: On the disordered CORD-r dataset, TPP achieved a massive +9.13 F1 gain over standard sequence labeling using a LayoutLMv3 backbone.
  • State-of-the-Art (SOTA): TPP achieved SOTA results on the FUNSD Entity Linking task (79.23 F1) and outperformed previous leading models in Reading Order Prediction (ROP).
  • Robustness to Shuffling: Experiments confirmed that TPP's performance remains stable even when input tokens are randomly shuffled, a feat impossible for traditional BIO-based models.

Conclusion

TPP provides a unified framework for three distinct tasks: NER (local paths), Entity Linking (links between paths), and Reading Order Prediction (global paths). While it carries a higher computational cost—requiring roughly 2.5x longer training time due to the $n \times n$ grid prediction—its ability to handle the "messiness" of real-world OCR makes it a significant advancement for document AI.

Summary updated

BibTeX
@inproceedings{zhang2023reading,
  author = {Chong Zhang and Ya Guo and Yi Tu and Huan Chen and Jinyang Tang and Huijia Zhu and Qi Zhang and Tao Gui},
  title = {{Reading Order Matters: Information Extraction from Visually-rich Documents by Token Path Prediction}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.emnlp-main.846},
}
Figure