Abstract
Deep learning models have achieved state-of-the-art performance in document image classification, yet their "black-box" nature remains a significant barrier to adoption in regulated industries. Traditional explainability (XAI) methods, designed for natural images, often fail to account for the unique structural characteristics of documents, such as text alignment and layout. This paper introduces DocXplain, a model-agnostic framework specifically engineered for document images. By utilizing multi-scale segmentation and feature ablation, DocXplain generates attribution maps that are more faithful to model logic and more interpretable to human users than existing benchmarks.
1. Introduction
Document image classification—the task of automatically categorizing documents like resumes, invoices, or memos—is a critical component of automated workflows in finance, law, and healthcare. While deep learning models excel at this task, understanding why a model classifies a document into a specific category is essential for auditing and bias detection. Existing XAI tools like LIME or Saliency maps often produce "noisy" visualizations when applied to documents, as they do not respect the semi-structured nature of text and layout. DocXplain addresses these limitations by treating documents as collections of meaningful structural components rather than arbitrary pixel clusters.
2. The DocXplain Framework
DocXplain is a two-stage, model-agnostic framework that requires no access to a model’s internal weights, making it compatible with any architecture from legacy convolutional neural networks (CNNs) to modern vision transformers.
2.1 Feature Segmentation
Unlike standard methods that use square patches or pixel gradients, DocXplain segments documents into meaningful "blobs" through a multi-scale approach:
- Foreground Segmentation: Using Otsu binarization and dilation, the method groups text and images. It employs three distinct kernel sizes to capture different granularities: individual words, horizontal lines, and vertical blocks or columns. This ensures the "grammar" of the document layout is preserved.
- Background Segmentation: A grid is generated over the white space, treating background patches as distinct features to determine if the model is relying on whitespace or margins for classification.
- Refinement: SLIC superpixels are used to decompose large components (e.g., tables), while denoising filters remove irrelevant artifacts.
2.2 Feature Ablation and Attribution
To quantify the importance of each segment, DocXplain performs systematic ablation. By removing a segment (replacing text with background or vice versa) and measuring the resulting drop in the model's confidence score, the framework assigns an importance value to that feature. This process results in a "feature attribution map" that highlights the specific words or layout elements driving the classification decision.
3. Experimental Setup
The researchers evaluated DocXplain across two primary benchmarks:
- RVL-CDIP: A large-scale dataset containing 400,000 images across 16 categories (e.g., emails, forms, scientific reports).
- Tobacco3482: A smaller, more complex dataset of 3,482 images characterized by significant class imbalance.
The method was tested against 10 different deep learning architectures, including VGG-16, EfficientNet, and ConvNeXt, and compared with 9 state-of-the-art XAI methods such as SHAP and Integrated Gradients.
4. Key Results and Discussion
4.1 Faithfulness and Consistency
Using the Area Over the Perturbation Curve (AOPC) metric, DocXplain demonstrated superior faithfulness compared to traditional XAI methods. This indicates that the features identified by DocXplain are truly the primary drivers of the model's output. Furthermore, DocXplain consistently ranked in the top three across all 10 tested models for sensitivity and infidelity metrics, highlighting its robustness across different architectures.
4.2 Human-Centric Interpretability
Qualitative analysis revealed that DocXplain produces significantly cleaner attribution maps. While gradient-based methods often produce sparse, scattered highlights on individual characters, DocXplain highlights coherent blocks of text or structural elements. This alignment with human visual perception makes the explanations more actionable for end-users.
4.3 Decoupling Content and Context
A unique advantage of the DocXplain_FG+BG variant is its ability to distinguish between content (text) and context (layout). This allows researchers to identify if a model is making decisions based on the actual information in a document or merely the visual arrangement of the page.
5. Limitations and Future Work
Despite its advantages, DocXplain relies on clean binarization, which may be challenging for low-quality or highly noisy scans. Additionally, because it requires multiple passes through the model for ablation, it is computationally more expensive than simple gradient-based methods. Future research will explore the integration of Optical Character Recognition (OCR) for direct text-based localization and extending the framework to multimodal models that process both image and text data simultaneously.
6. Conclusion
DocXplain represents a significant step forward in making document classification models transparent. By respecting the inherent structure of documents, it provides a reliable and interpretable XAI solution that outperforms general-purpose methods in both faithfulness and clarity.
Summary updated