Abstract
Handwritten Document Recognition (HDR) has evolved from complex multi-stage pipelines to end-to-end Document Attention Networks (DAN). However, the autoregressive nature of standard DANs, which predict characters sequentially, creates a significant inference bottleneck. This paper introduces Faster DAN, a novel architecture that utilizes a two-pass prediction strategy and document positional encoding to recognize text lines in parallel. Faster DAN achieves a 4x to 5.8x speedup over the original DAN while maintaining competitive accuracy across major benchmarks.
Introduction
The transition to end-to-end models in HDR has simplified document processing by allowing models to recognize text and layout structure simultaneously. Despite their power, these models are typically autoregressive: for a document containing 1,000 characters, the model must perform 1,000 sequential iterations. This sequential dependency prevents the utilization of parallel processing capabilities in modern GPUs, leading to high latency in production environments.
Faster DAN addresses this by moving away from character-by-character prediction toward line-level parallelism. By identifying the start of each line first, the model can then predict the remainder of all lines simultaneously.
Methodology
The core of Faster DAN is a two-pass strategy supported by a specialized 2D positional encoding scheme.
Two-Pass Prediction Strategy
The recognition process is divided into two distinct phases:
- First Pass (Sequential): The model predicts layout tokens (e.g.,
<paragraph>) and the first character of every text line. This pass effectively maps the document's structure and identifies the starting points for all text sequences. - Second Pass (Parallel): Using the starting characters as anchors, the model predicts the subsequent characters for all lines in parallel. In each iteration of this pass, the model predicts the $n$-th character for every line across the document.
Document Positional Encoding
To manage parallel sequences, the model requires a way to distinguish between characters in different lines. Faster DAN employs a 2D positional encoding scheme that concatenates a line index with a character index within the line. This allows the attention mechanism to maintain context across multiple parallel "threads" of text, resolving ambiguities by looking at the surrounding text context.
Experimental Evaluation
The model was evaluated on three major public benchmarks: READ 2016 (Early Modern German), RIMES 2009 (French mail), and MAURDOR (heterogeneous correspondence).
Performance and Efficiency
Faster DAN demonstrates a massive reduction in inference time. On the READ 2016 single-page dataset, inference time was reduced from 4.6 seconds to 0.9 seconds. On double-page spreads, the number of iterations dropped from over 1,000 to just 76, representing a significant efficiency gain for complex documents.
In terms of accuracy, Faster DAN achieved state-of-the-art results in layout recognition (LOER and mAP) on READ 2016. While its Character Error Rate (CER) remains competitive, it is slightly higher than the original DAN on datasets with high layout variability, such as RIMES, due to the increased difficulty of the initial structural pass.
Conclusion
Faster DAN represents a significant step forward in making end-to-end HDR practical for large-scale applications. By identifying line-level parallelism as the "sweet spot" for optimization, the authors achieve substantial speedups without sacrificing the benefits of end-to-end learning. Future work may explore extending this parallelization to the paragraph level to further enhance contextual modeling.
Summary updated