NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Test-Time Adaptation for Visual Document Understanding

Sayna Ebrahimi, Sercan O Arik, Tomas Pfister

Abstract

For visual document understanding (VDU), self-supervised pretraining has been shown to successfully generate transferable representations, yet, effective adaptation of such representations to distribution shifts at test-time remains to be an unexplored area. We propose DocTTA, a novel test-time adaptation method for documents, that does source-free domain adaptation using unlabeled target document data. DocTTA leverages cross-modality self-supervised learning via masked visual language modeling, as well as pseudo labeling to adapt models learned on a source domain to an unlabeled target domain at test time. We introduce new benchmarks using existing public datasets for various VDU tasks, including entity recognition, key-value extraction, and document visual question answering. DocTTA shows significant improvements on these compared to the source model performance, up to 1.89% in (F1 score), 3.43% (F1 score), and 17.68% (ANLS score), respectively.

Introduction: The Challenge of Domain Shift in VDU

Visual Document Understanding (VDU) is critical for automating the processing of diverse documents like invoices, medical records, and tax forms. While state-of-the-art models like LayoutLM have achieved impressive results, they often struggle with domain shift. A model trained on high-quality digital invoices may fail when processing blurry, hand-filled receipts or documents with unfamiliar layouts.

Traditionally, Unsupervised Domain Adaptation (UDA) has been used to mitigate these shifts. However, UDA requires access to the original "source" training data to align it with the "target" data. In many real-world scenarios, source data is inaccessible due to privacy regulations (e.g., GDPR, HIPAA) or proprietary restrictions. To address this, we propose DocTTA, a "source-free" test-time adaptation framework that updates models using only the unlabeled documents encountered during inference.

The DocTTA Framework

DocTTA adapts a pre-trained VDU model (specifically LayoutLMv2) to a new target domain using three joint objectives:

  1. Masked Visual Language Modeling (MVLM): By randomly masking 15% of text tokens and tasking the model with predicting them using visual and layout context, DocTTA forces the model to internalize the structural and linguistic patterns of the new domain.
  2. Uncertainty-Aware Pseudo-Labeling: The model generates its own labels for target data. To prevent error propagation, Shannon’s entropy is used to filter these predictions, ensuring the model only learns from high-confidence "pseudo-labels."
  3. Diversity Objective: A diversification loss is employed to prevent the model from collapsing into predicting only the most frequent classes, encouraging a balanced distribution of predictions across the label space.

This online framework updates model weights batch-by-batch as new data is processed, enabling real-time adaptation.

Benchmarking Adaptation

To evaluate DocTTA, we established three new benchmarks by re-splitting existing public datasets to simulate realistic distribution shifts:

  • FUNSD-TTA: Evaluates entity recognition (e.g., identifying headers vs. questions) across shifts in document sparsity.
  • SROIE-TTA: Focuses on key-value extraction from receipts, simulating shifts in visual quality (e.g., clean scans vs. blurry or rotated images).
  • DocVQA-TTA: A Visual Question Answering benchmark spanning four domains: Emails & Letters, Figures & Diagrams, Tables & Lists, and Layout-heavy documents.
Overview of the VDU tasks and domain shifts used for benchmarking DocTTA, including VQA, Key-value Extraction, and Named Entity Recognition.

Results and Key Insights

DocTTA demonstrates consistent performance gains over non-adapted "source-only" models:

  • Entity Recognition (FUNSD): 3.43% improvement in F1 score.
  • Key-Value Extraction (SROIE): 1.89% improvement in F1 score.
  • Document VQA: Significant gains in ANLS (Average Normalized Levenshtein Similarity), notably a 17.68% improvement when adapting from Figures to Emails.

Key findings include:

  • Cross-Modality is Essential: Effective adaptation in VDU requires simultaneously adjusting the relationships between text, image, and layout.
  • Source-Free Advantages: In some DocVQA scenarios, DocTTA outperformed source-available methods (DocUDA), as the source data can sometimes bias the model away from a significantly different target domain.
  • Improved Calibration: Beyond accuracy, DocTTA improves model calibration, making confidence scores more reliable for human-in-the-loop validation.

Conclusion and Future Directions

While DocTTA offers a powerful solution for source-free adaptation, it introduces computational overhead due to test-time backpropagation. Future work will explore handling "open-set" scenarios where new categories emerge and reducing hyperparameter sensitivity in zero-knowledge environments. Despite these challenges, DocTTA represents a significant step toward robust, privacy-preserving document understanding in the wild.

Summary updated

BibTeX
@article{ebrahimi2023test,
  author = {Sayna Ebrahimi and Sercan O Arik and Tomas Pfister},
  title = {{Test-Time Adaptation for Visual Document Understanding}},
  journal = {Accepted by TMLR},
  year = {2023},
  url = {https://openreview.net/forum?id=zshemTAa6U},
}
Figure