DocTTT: Test-Time Training for Handwritten Document Recognition Using Meta-Auxiliary Learning

Wenhao Gu, Li Gu, Ziqiang Wang, Ching Yee Suen, Yang Wang · DOI

DocTTT: Test-Time Training for Handwritten Document Recognition Using Meta-Auxiliary Learning

Introduction

Handwritten Document Recognition (HDR) is a complex task because handwriting is inherently personal. Variations in pen pressure, flourishes, and layout conventions create a "generalization gap" for static models trained on fixed datasets. Most current HDR systems use a "train-then-freeze" approach, which fails when encountering a writing style or document quality not represented in the training data. DocTTT addresses this by allowing the model to "learn" the specific visual style of a document at the moment of recognition through test-time training.

The DocTTT Framework

The core innovation of DocTTT is the concept of Test-Time Training (TTT). Instead of a standard forward pass, the model performs a localized optimization on the specific input image it is trying to recognize. This adaptation is driven by a dual-branch architecture sharing a common encoder backbone.

Primary and Auxiliary Branches

The model utilizes two distinct pathways:

  • Primary Branch: An encoder-decoder setup that transforms the image into a flattened sequence of XML tokens, representing both the text content and the document's layout.
  • Auxiliary Branch: A Masked Autoencoder (MAE) that attempts to reconstruct the original image from a version where 75% of the pixels are hidden.
Figure 2: Input document with bounding boxes and its corresponding XML-based transcription.

Meta-Auxiliary Learning

To ensure that the auxiliary task effectively improves the primary recognition task, the authors employ Model-Agnostic Meta-Learning (MAML). The model is trained to find a parameter initialization that is highly adaptable.

In the inner loop, the model updates its shared weights to minimize the MAE reconstruction loss on a specific image. In the outer loop, the system evaluates if these updated weights actually improved the recognition of the text (the primary task). This meta-learning framework ensures that the reconstruction task is mathematically aligned with the goal of character recognition, preventing "catastrophic forgetting" during the quick test-time update.

Visual Reconstruction with SSIM

A key technical detail is the use of the Structural Similarity Index Measure (SSIM) loss instead of standard Mean Squared Error (MSE) for the reconstruction task. SSIM is significantly more sensitive to textures and fine strokes—elements that are crucial for distinguishing handwritten characters. By forcing the model to "understand" the visual structure of the page via reconstruction, the shared encoder learns the specific visual "language" of the author without requiring ground-truth labels at test time.

Figure 6: Example of masked images used in the auxiliary reconstruction task.

Experimental Results

DocTTT was evaluated on three gold-standard benchmarks: READ2016 (early modern German), IAM (English paragraphs), and RIMES2011 (French letters). The model consistently outperformed existing static state-of-the-art methods:

  • READ2016: Achieved a Character Error Rate (CER) of 3.18%, beating the previous best of 3.43%.
  • IAM: Achieved a CER of 4.22%, improving upon the previous SOTA of 4.45%.
  • RIMES2011: Reached a CER of 2.33%.

Qualitatively, the authors demonstrated that DocTTT can correct initial prediction errors (such as misreading similar-looking characters) simply by adapting to the author's specific way of forming letters during the test-time update.

Conclusion and Future Work

DocTTT represents a significant shift from static to adaptive HDR systems. By treating every document as a unique learning opportunity, the framework bridges the generalization gap inherent in human handwriting. While the computational overhead of performing gradient updates during inference remains a challenge for real-time applications, the gains in accuracy demonstrate the power of meta-auxiliary learning. Future research may explore applying this adaptation strategy to other document analysis tasks, such as table extraction or form parsing.

Summary updated

BibTeX
@inproceedings{gu2025docttt,
  author = {Wenhao Gu and Li Gu and Ziqiang Wang and Ching Yee Suen and Yang Wang},
  title = {{DocTTT: Test-Time Training for Handwritten Document Recognition Using Meta-Auxiliary Learning}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2025},
  url = {https://openreview.net/forum?id=HGQX7RotIB},
}
Figure