iDocV2: Leveraging Self-Supervision and Open-Set Detection for Improving Pattern Spotting in Historical Documents

José M. Saavedra, Christopher Stears, Marcelo Pizarro, Cristóbal Loyola, Luis Aros
deepCVL, Universidad de los Andes, Santiago, Chile
arXiv preprint, 2026

Computer Vision Lab · Universidad de los Andes

iDocV2: region proposal with Grounding DINO, the iDoc encoder and a sparse similarity-search decoder

Find every occurrence of an illustration, initial or ornament across a collection of medieval books from a single example: an encoder adapted by self-supervision plus an open-set detector, ten times faster than dense matching and best on the hardest queries.

10×faster: 0.72 s per search instead of about 7 s
0.645pattern-spotting mAP on DocExplore (previous best 0.494)
0.612mAP on small non-square queries, the hardest (previous 0.427)
100×fewer comparisons: ~112 regions per page instead of 22,080 positions

Abstract

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.

The problem

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.

How it works

iDocV2 replaces dense matching with sparse matching over a few meaningful regions, and uses an encoder that understands historical documents.

  • Offline region proposal. Grounding DINO, an open-set detector, is prompted with general concepts (figure, building, roof, sketch, person, symbol); duplicates are removed with non-maximum suppression (IoU 0.5). Each page becomes about 112 candidate regions.
  • iDoc encoder. iBOT (ViT) adapted to medieval material with LoRA: 3.53 M trainable parameters, 4.11% of the 85.8 M of iBOT. It is trained by self-supervision on 270,000 regions sampled from 1,852,824 found in 12,947 pages of 14 Books of Hours (HORAE).
  • Sparse decoder. The query and every region are encoded with the class token and ranked by cosine similarity. iDocV2 adds non-maximum suppression over the results to remove false positives.
DocExplore pages with regions of interest found by Grounding DINO
DocExplore pages with the regions proposed by Grounding DINO. The encoder compares the query only with these regions.

Data

  • DocExplore (evaluation): 1,500 pages and 1,447 graphical queries in 35 categories, from manuscripts of the 10th to 16th centuries held at the Municipal Library of Rouen.
  • HORAE (self-supervised training only): Books of Hours, late-medieval prayer books; 500 digitized manuscripts and 107,227 images.

Results

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.

Pattern spotting mAP on DocExplore by query size and aspect ratio. Best per row in bold.
QueryCuri et al.iDoc (v1)iDoc + NMSiDocV2 (mix + NMS)
Big, square0.8770.7860.8680.860
Small, square0.8280.7980.8130.821
Big, non-square0.7490.6410.6790.652
Small, non-square0.4270.5880.6020.612
Overall mAP0.4940.6200.6370.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.

What makes it work

Overall pattern-spotting mAP of the iDoc encoder when one design choice is changed.
VariantOverall mAP
iDoc: iBOT + LoRA, Grounding DINO regions, class token0.620
iBOT trained from scratch instead of LoRA adaptation0.602
Averaged patch features instead of the class token0.521
Random regions instead of semantic regions for training0.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.

Qualitative results

Pattern spotting results for queries of different sizes and aspect ratios
Queries of different sizes and aspect ratios (left) and the occurrences found across the collection.

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.

BibTeX

@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}
}