QueryForm: A Simple Zero-shot Form Entity Query Framework

Zifeng Wang, Zizhao Zhang, Jacob Devlin, Chen-Yu Lee, Guolong Su, Hao Zhang, Jennifer G. Dy, Vincent Perot, Tomas Pfister

Abstract

QueryForm is a novel framework designed for zero-shot document entity extraction (DEE). Traditional DEE models rely on fixed schemas and extensive manual labeling for each new document type, which hinders scalability. QueryForm addresses this by reformulating entity extraction as a query-based task. It introduces a dual-prompting mechanism—comprising a Schema Prompt (S-Prompt) and an Entity Prompt (E-Prompt)—to generalize across diverse document layouts. Furthermore, the model leverages "QueryWeb," a massive dataset derived from millions of webpages with structured HTML, as a proxy for form-like documents during pre-training. Experimental results demonstrate that QueryForm sets new state-of-the-art benchmarks in zero-shot and few-shot scenarios, outperforming significantly larger models.

Introduction

Automating data extraction from structured documents, such as invoices, receipts, and medical forms, is a critical task in document AI. This process, known as Document Entity Extraction (DEE), typically follows a supervised learning paradigm where models are trained on fixed schemas with thousands of manually labeled examples. However, this approach fails to scale when encountering new document types with unique layouts and fields.

To overcome these limitations, we present QueryForm, a framework designed for zero-shot transfer. QueryForm shifts the paradigm from static classification to dynamic query-answering. By decoupling the extraction logic from specific document types, the model can identify entities in previously unseen forms.

Overview of the QueryForm framework showing the progression from webpage pre-training to zero-shot prediction on new document types.

The QueryForm Framework

Dual Prompting Mechanism

The core of QueryForm is its dual-prompting strategy, which provides the model with both global context and specific extraction targets:

  • S-Prompt (Schema): This prompt captures the document's category (e.g., "Invoice"). During fine-tuning, it is represented as a learnable vector that helps the model adapt to the general layout patterns of a document class.
  • E-Prompt (Entity): This prompt specifies the target field (e.g., "Total Amount").

By separating these two components, QueryForm learns a generalized "search" capability, allowing it to relate semantic queries to spatial document layouts.

Detailed architectural view of the two-stage training process: Stage 1 (Webpage Pre-training) and Stage 2 (Form-like Document Fine-tuning).

QueryWeb Pre-training

A significant challenge in DEE is the lack of large-scale labeled data. QueryForm addresses this by utilizing the structured nature of the web. Webpages often function as digital forms, where HTML tags provide implicit "Key: Value" labels. The researchers curated QueryWeb, a dataset of millions of webpages, using domain names as schema proxies and HTML snippets as entity labels. This pre-training phase allows the model to learn the fundamental relationship between text, structure, and queries before ever seeing a physical document.

Model Architecture

QueryForm utilizes the Extended Transformer Construction (ETC) backbone. This architecture is optimized for long-sequence inputs and incorporates Rich Attention, which encodes 2D spatial coordinates. This allows the model to understand the relative positions of text elements—a crucial feature for interpreting complex form layouts—without the computational overhead of heavy vision-based backbones.

Evaluation and Results

QueryForm was evaluated on standard benchmarks including FUNSD, XFUND, and a new financial dataset called "Payment."

  • Zero-shot Performance: QueryForm established new state-of-the-art results, improving average F1 scores on XFUND by 4.6% to 10.1%.
  • Few-shot Robustness: In 1-shot scenarios, QueryForm maintained an F1 score of 89.26, whereas traditional supervised models like FormNet suffered from severe overfitting.
  • Efficiency: Despite having significantly fewer parameters (82M–185M) than competitors like LayoutXLM (up to 625M), QueryForm consistently delivered superior performance, highlighting the effectiveness of its query-based approach.

Conclusion and Future Work

QueryForm demonstrates that reformulating DEE as a query-answering task, combined with web-scale pre-training, is a powerful strategy for zero-shot document understanding. While the model shows remarkable generalization, future work will focus on "open-world" scenarios where queried entities may not be present in the document, as well as refining prompt sensitivity. By bridging the gap between digital web structures and physical document layouts, QueryForm paves the way for more scalable and flexible document AI systems.

Summary updated

BibTeX
@inproceedings{wang2023queryform,
  author = {Zifeng Wang and Zizhao Zhang and Jacob Devlin and Chen-Yu Lee and Guolong Su and Hao Zhang and Jennifer G. Dy and Vincent Perot and Tomas Pfister},
  title = {{QueryForm: A Simple Zero-shot Form Entity Query Framework}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.findings-acl.255},
}
Figure