Introduction
Traditional document understanding systems, such as Document Layout Analysis (DLA) and Key Information Extraction (KIE), typically operate on a closed-set principle. These models are trained to recognize a fixed set of predefined categories—such as titles, authors, or specific table formats. However, real-world document processing often requires a higher degree of flexibility. Users frequently need to extract highly specific, custom regions of interest (RoIs), such as unique stamps, specialized charts, or non-standardized table structures, which may not have been present in the training data.
To address this limitation, this research introduces the task of RoI-Matching. Unlike traditional methods, RoI-Matching is class-agnostic and open-set. It allows a user to provide a "visual prompt"—a reference image with a highlighted mask—to find matching regions across target documents without requiring retraining or text-based descriptions.
The Limitations of Current Approaches
Current solutions for flexible document analysis generally fall into two categories, both of which have significant drawbacks:
- Rigid Supervised Models: Standard DLA and KIE models are highly accurate for known categories but fail completely when encountering novel layouts or custom user requirements.
- Multi-modal Large Language Models (MLLMs): While MLLMs like Qwen2-VL can handle open-set queries via text prompts, they are computationally expensive and often struggle with the precise pixel-level localization required for complex document layouts. Furthermore, describing complex visual structures in text is often ambiguous compared to providing a visual example.
Methodology: The RoI-Matcher
The authors propose RoI-Matcher, a streamlined and efficient baseline model designed specifically for the RoI-Matching task. The architecture focuses on three core components:
Visual Perception and Early Masking
RoI-Matcher utilizes a Siamese network (based on ResNet-50) to extract multi-level features from both the reference and target images simultaneously. A key finding in this research is the importance of Early Masking. By multiplying the user's visual prompt (the binary mask) with the reference features before they pass through the Feature Pyramid Network (FPNC), the model preserves critical semantic features of the source domain that would otherwise be lost.
Cross-Granularity Attention
To manage the high resolution of document images without excessive computational overhead, the model employs grid-sampling and flattening of features. A Multi-Head Cross-Attention mechanism is then used to project the visual prompt from the reference domain into the target domain, allowing the model to "search" for the prompt's characteristics within the target document.
Overlap-Aware Segmentation
Document elements are often densely packed or overlapping (e.g., a signature over a text block). To handle this, RoI-Matcher adopts a segmentation head inspired by the Pixel Aggregation Network (PAN) used in scene text detection. Instead of a simple binary mask, the model outputs a 6-channel mask representing regions, core kernels, and similarity vectors. This approach allows the system to accurately separate and distinguish between tightly clustered instances.
RoI-Matching-Bench
To evaluate the task, the authors developed RoI-Matching-Bench, a new benchmark dataset sourced from diverse document collections (SVRD, POIE, SROIE, D4LA, and M6Doc). The benchmark is categorized into three difficulty levels:
- Level I (Easy): Similar visual elements in standardized positions (e.g., ID cards).
- Level II (Medium): Similar visual elements in varying positions (e.g., diverse receipts).
- Level III (Hard): Significant variance in both appearance and position (e.g., figures and equations across different academic journals).
Experimental Results
RoI-Matcher demonstrates a significant performance advantage over existing few-shot segmentation and MLLM-based methods.
- Accuracy: The model achieved 87.3% mIoU and 83.9% F-Measure across the benchmark. In contrast, the best Cross-Domain Few-Shot Segmentation (CD-FSS) models struggled significantly, particularly on Level III data where they achieved only a 15.1% F-Measure compared to RoI-Matcher’s 72.3%.
- Efficiency: RoI-Matcher is designed for real-world deployment. It processes an image in just 0.056 seconds (149.3 GFlops). For comparison, Qwen2-VL-7B takes approximately 3.121 seconds per image, making RoI-Matcher over 50 times faster while maintaining higher accuracy on complex matching tasks.
Conclusion and Future Directions
RoI-Matcher provides a robust, efficient, and flexible solution for the emerging task of class-agnostic document region matching. By prioritizing visual prompts over text and implementing early masking with a kernel-based segmentation head, it overcomes the rigidity of traditional models and the latency of MLLMs.
Future work aims to evolve the model from a uni-modal visual system to a multi-modal one by incorporating linguistic features. Additionally, the authors plan to expand the model to support multi-shot learning and parallel inference for multiple different RoIs simultaneously.
Summary updated