Considering the imminent massification of digital books, it has become critical to facilitate searching collections through graphical patterns. Current strategies for document retrieval and pattern spotting in historical documents still need to be improved. State-of-the-art strategies achieve an overall precision of 0.494 for pattern spotting, where the precision for small non-square queries reaches 0.427. In addition, the processing time is excessive, requiring up to 7 seconds for searching in the DocExplore dataset due to a dense-based strategy used by SOTA models.
Therefore, we propose a new model based on a better encoder (iDoc), trained under a self-supervised strategy, and an open-set detector to accelerate searching. Our model achieves competitive results with state-of-the-art pattern spotting and document retrieval, improving speed by 10x. Furthermore, our model reaches a new SOTA performance on the small non-square queries, achieving a new precision of 0.612. Different from the previous version, this leverages non-maximum suppression to reduce false positives.
Libraries are digitizing their historical collections, but searching them still relies on text: OCR and handwriting recognition. In medieval books the illustrations, decorated initials and ornaments are a large part of the content, and text search cannot reach them.
Pattern spotting answers a visual question: given a crop of one pattern, find every place it appears across the collection. The previous state of the art (Curi et al., 2022) correlates the query densely with every position of every page. It reaches an overall mAP of 0.494, drops to 0.427 for small, elongated queries, and needs about 7 seconds per search.
iDocV2 replaces dense matching with sparse matching over a few meaningful regions, and uses an encoder that understands historical documents.

iDoc is clearly better on small and non-square patterns, the most difficult and the most frequent in practice, and the full iDocV2 pipeline sets a new overall best.
| Query | Curi et al. | iDoc (v1) | iDoc + NMS | iDocV2 (mix + NMS) |
|---|---|---|---|---|
| Big, square | 0.877 | 0.786 | 0.868 | 0.860 |
| Small, square | 0.828 | 0.798 | 0.813 | 0.821 |
| Big, non-square | 0.749 | 0.641 | 0.679 | 0.652 |
| Small, non-square | 0.427 | 0.588 | 0.602 | 0.612 |
| Overall mAP | 0.494 | 0.620 | 0.637 | 0.645 |
For document retrieval (which pages contain the pattern?) iDoc reaches an overall mAP of 0.789 against 0.799 for Curi et al.; a Mann–Whitney test gives p = 0.47, so the two are statistically equivalent, and iDoc is ten times faster.
| Variant | Overall mAP |
|---|---|
| iDoc: iBOT + LoRA, Grounding DINO regions, class token | 0.620 |
| iBOT trained from scratch instead of LoRA adaptation | 0.602 |
| Averaged patch features instead of the class token | 0.521 |
| Random regions instead of semantic regions for training | 0.448 |
Semantic regions matter most (+17.2 points over random crops). LoRA adaptation adds 7 points on big non-square queries while training 4% of the parameters, and avoids the catastrophic forgetting of full fine-tuning.

Measured on the same GPU (an RTX A6000 Ada), a search over DocExplore takes 720 ms instead of about 7 s, which makes pattern search practical for large libraries.
@article{saavedra2026idocv2,
title = {{iDocV2}: Leveraging Self-Supervision and Open-Set Detection for Improving Pattern Spotting in Historical Documents},
author = {Saavedra, Jose M. and Stears, Christopher and Pizarro, Marcelo and Loyola, Crist{\'o}bal and Aros, Luis},
journal = {arXiv preprint arXiv:2604.16726},
year = {2026}
}