Generative compositor for few-shot visual information extraction

Zhibo Yang, Wei Hua, Sibo Song, Cong Yao, Yingying Zhu, Wenqing Cheng, Xiang Bai

TL;DR

The Generative Compositor (GC) is a novel framework that transforms Visual Information Extraction (VIE) from a rigid classification task into a flexible, prompt-based retrieval process. By emulating a "compositor" that retrieves and assembles text blocks based on semantic prompts, it achieves state-of-the-art results and shows massive performance gains in few-shot scenarios—improving 1-shot accuracy on the CORD dataset by over 23%.

What Problem Does This Paper Address?

Visual Information Extraction (VIE) is the process of turning visually rich documents (like receipts, invoices, and forms) into structured data. While deep learning has made strides here, two major "bottlenecks" remain:

  1. The Data Scarcity (Few-Shot) Problem: There is a nearly infinite variety of document layouts and languages. Most specific document types have very little training data (a "long-tail" distribution), making it hard for standard models to generalize.
  2. The OCR Ordering Mess: Traditional models often rely on the "reading order" provided by OCR engines. If the OCR engine gets the sequence wrong (due to complex tables or skewed scans), the extraction fails.

Current generative models (like Donut) often hallucinate text, while classification models (like LayoutLM) struggle when they encounter a category they haven't seen thousands of times during training.

Methods

The authors introduce the Generative Compositor (GC), a hybrid pointer-generator network. Instead of just labeling a word as "Total Price," the model generates a "matcher vector" for a specific prompt (e.g., "What is the total price?") and finds the best matching text blocks in the document.

Key Innovations:

  • Prompt-Aware Resampler (PAR): Inspired by the Flamingo architecture, this module distills multi-modal information (text, layout, and image) by specifically attending to the prompts. This ensures the model's internal representation is "primed" to look for the specific information requested.
  • Generative Matcher: Unlike standard sequence labeling which uses fixed weights, this module produces dynamic weights conditioned on the input image and the prompt. It essentially "points" to the correct OCR tokens.
  • Spatial Pre-training Strategies: To teach the model about document geometry without needing labeled VIE data, the authors devised three tasks:
  • Match to Fill (MTF): Predicting missing text between two tokens to learn reading order.
  • Search One Direction (SOD): Finding the $k$-nearest words in a specific direction (Up/Down/Left/Right).
  • Search All Directions (SAD): Learning pairwise distances in 2D space to understand regional context.

Datasets

The model was pre-trained on RVL-CDIP (400k document images) and DocILE (6.7k real business documents). Evaluation was conducted on three major benchmarks:

  • FUNSD: Form understanding in noisy scanned documents.
  • CORD: Consolidated Receipt Dataset for post-OCR parsing.
  • POIE: A dataset for information extraction from real-scene product images (nutrition labels).

Key Insights and Ideas

  • Matching > Classification: By treating extraction as a matching problem between a prompt and a document, the model can handle "unseen" categories much better. If you give it a new prompt, it uses its semantic understanding of the words in that prompt to find the answer, rather than relying on a pre-defined output neuron.
  • Trusting OCR (Mostly): Unlike "OCR-free" models that try to recognize text and extract info simultaneously (and often hallucinate), GC "trusts" the OCR text but "distrusts" the OCR order. It treats the document as a pool of fragments to be re-assembled.
  • Spatial Awareness is Key: The directional pre-training (SOD/SAD) is what allows the model to understand that a "Total" label is usually to the left of or above the actual price, regardless of the raw text sequence.

Key Results

  • Full-Shot SOTA: On the FUNSD dataset, GC achieved a 94.33% F1 score, surpassing the previous state-of-the-art by 1.47%.
  • Few-Shot Dominance: This is where the model shines. In a 1-shot setting (training on only one example) on the CORD dataset, GC achieved 62.16% F1, while the baseline LayoutLMv3 struggled at 38.95%—a staggering 23.21% improvement.
  • Robustness to Chaos: When the authors intentionally shuffled the order of OCR text blocks, GC's performance remained stable, while traditional models saw significant drops. This proves the "Compositor" approach successfully ignores faulty reading orders.

Limitations and Future Work

  • Multilingual Support: The current study focuses primarily on Latin-based scripts. The authors note that languages with richer character sets (Chinese, Japanese, Korean) pose greater challenges for visual modules.
  • Zero-Shot Exploration: While the model excels at few-shot learning, the authors aim to explore true zero-shot VIE by integrating even more powerful, large-scale language models.
  • Inference Speed: While competitive, the generative nature of the decoder means that longer output sequences (more entities to extract) can slow down inference compared to simple classification layers.

Summary updated

BibTeX
@article{yang2025generative,
  author = {Zhibo Yang and Wei Hua and Sibo Song and Cong Yao and Yingying Zhu and Wenqing Cheng and Xiang Bai},
  title = {{Generative compositor for few-shot visual information extraction}},
  journal = {Pattern Recognition},
  year = {2025},
  url = {https://openreview.net/forum?id=NGWYtDVeqj},
}

Loading related content...

Figure