DocXclassifier: towards a robust and interpretable deep neural network for document image classification

Saifullah Saifullah, Stefan Agne, Andreas Dengel, Sheraz Ahmed

TL;DR

DocXClassifier is a new deep learning architecture that achieves state-of-the-art accuracy in document image classification while being both robust to real-world distortions and "interpretable by design." By replacing standard pooling with an attention-based mechanism, the model generates feature importance maps in a single forward pass, eliminating the need for slow and often unreliable post-hoc explanation methods.

What Problem Does This Paper Address?

Deep learning (DL) has revolutionized automated document processing, but two major hurdles prevent its safe deployment in high-stakes industrial settings: opacity and fragility.

Most top-performing models are "black boxes"—they provide a classification (e.g., "This is an invoice") without explaining why. When these models fail or exhibit bias (like discriminating against certain resumes), it is difficult to diagnose the cause. Furthermore, while models perform well on clean datasets, they often crumble when faced with real-world "out-of-distribution" data, such as blurry mobile captures, ink-bleeds, or scanned noise. The authors of DocXClassifier aim to solve both by creating a model that is inherently interpretable and significantly more resilient to data corruption.

Methods

The authors build upon the ConvNeXt architecture, a modern convolutional neural network that incorporates design successes from Vision Transformers (ViTs).

The core innovation is the Attention-Based Pooling mechanism. In standard networks, a "Global Average Pooling" layer flattens the final feature map, losing spatial context. DocXClassifier instead uses a trainable "class token" (similar to those in Transformers) that interacts with the feature map via a scaled dot-product attention operation.

The complete configuration of DocXClassifier, highlighting the transition from ConvNeXt blocks to the Attention-Based Pooling stage.

This allows the model to "weigh" the importance of different document regions. Because this attention happens during the prediction, the resulting importance maps are a faithful representation of the model's internal logic.

To bolster robustness, the authors devised a two-stage training strategy using a cocktail of aggressive data augmentations:

  • RandAugment: Randomly applies color, brightness, and geometric shifts.
  • RandomErasing: Randomly masks parts of the image to simulate occlusions.
  • Mixup & CutMix: Blends or patches together images from different classes to force the model to learn more generalized features.
Examples of document images after applying RandomErasing, CutMix, and Mixup augmentations.

Datasets

The model was evaluated on two industry-standard benchmarks:

  1. RVL-CDIP: A massive dataset of 400,000 grayscale images across 16 document categories (letters, forms, resumes, etc.).
  2. Tobacco3482: A smaller, more challenging dataset of 3,482 images.

For robustness testing, the authors used the "D" (Distorted) variants of these datasets (RVL-CDIP-D and Tobacco3482-D), which contain 21 different types of novel distortions like Gaussian noise, motion blur, and "digital" corruptions.

Key Insights and Ideas

  • Inherent vs. Post-hoc Interpretability: Most researchers use tools like Grad-CAM or LIME to explain models after they are trained. The authors argue these are often "unfaithful" or computationally expensive. By making the model interpretable by design, DocXClassifier produces "smoother" and more logical explanations (e.g., highlighting the header of a letter or the "Experience" section of a resume) without extra overhead.
  • The Robustness-Accuracy Trade-off is a Myth: Often, making a model more robust decreases its accuracy on clean data. DocXClassifier proves the opposite: its robust training recipe actually helped it set new state-of-the-art records on clean benchmarks.
  • Architecture Scaling: The authors provide three variants (Base, Large, and XL) to suit different computational budgets.
Table showing the number of channels and blocks for the three DocXClassifier variants.

Key Results

  • State-of-the-Art Performance: DocXClassifier-XL achieved 94.17% accuracy on RVL-CDIP, surpassing the previous best image-based model by 1.48%. On Tobacco3482, it reached 95.57%.
  • Superior Robustness: The model outperformed existing approaches on 19 out of 21 distortion types. It was particularly effective against noise and blur, though it showed some sensitivity to extreme contrast changes.
  • Efficiency: Despite the added attention mechanism, the model remains highly efficient. The "Base" variant can process images in roughly 6.5 ms, making it suitable for real-time industrial pipelines.

Limitations and Future Work

While DocXClassifier is highly robust, the authors noted that the largest variant (XL) showed signs of overfitting on the smaller Tobacco3482 dataset. Additionally, the model's performance dipped when faced with high-contrast distortions on the RVL-CDIP-D set.

An interesting qualitative finding was that the model often fixates on identification numbers (like serial numbers or dates) to classify documents. The authors suggest that future work should investigate whether the model is relying too heavily on these specific strings rather than the overall document layout, which could be a potential point of failure if those numbers are redacted or missing.

Summary updated

BibTeX
@article{saifullah2024docxclassifier,
  author = {Saifullah Saifullah and Stefan Agne and Andreas Dengel and Sheraz Ahmed},
  title = {{DocXclassifier: towards a robust and interpretable deep neural network for document image classification}},
  journal = {Int. J. Document Anal. Recognit.},
  year = {2024},
  doi = {10.1007/s10032-024-00483-w},
}
Figure