A join is a set of manuscript fragments identified as originally emanating from the same manuscript. We study manuscript join retrieval: Given a query image of a fragment, retrieve other fragments originating from the same physical manuscript. We propose Bag of Bags (BoB), an image-level representation that replaces the global-level visual codebook of classical Bag of Words (BoW) with a fragment-specific vocabulary of local visual words. Our pipeline trains a sparse convolutional autoencoder on binarized fragment patches, encodes connected components from each page, clusters the resulting embeddings with per-image k-means, and compares images using set-to-set distances between their local vocabularies. Evaluated on fragments from the Cairo Genizah, the best BoB variant (viz. Chamfer) achieves Hit@1 of 0.78 and MRR of 0.84, compared to 0.74 and 0.80, respectively, for the strongest BoW baseline (BoW-RawPatches-χ2), a 6.1% relative improvement in top-1 accuracy. We furthermore study a mass-weighted BoB-OT variant that incorporates cluster population into prototype matching and present a formal approximation guarantee bounding its deviation from full component-level optimal transport. A two-stage pipeline using a BoW shortlist followed by BoB-OT reranking provides a practical compromise between retrieval strength and computational cost, supporting applicability to larger manuscript collections. The code and dataset are available at https://github.com/TAU-CH/midrash_bob.
Figures & tables
Figure 1: Representative join groups from the Cairo Genizah benchmark. Each row shows fragments originating from the same physical manuscript, held among different institutions worldwide. (The blue backgrounds were designed for easy algorithmic segmentation.)
Figure 2: Overview of the proposed pipeline.
Family
Method
Hit@1
mAP@1
Hit@5
mAP@5
Hit@10
mAP@10
MRR
MacroF1@1
Pooling
MeanPool-Cosine
0.545
0.545
0.773
0.469
0.841
0.475
0.642
0.384
MaxPool-L2
0.307
0.307
0.534
0.288
0.648
0.300
0.424
0.187
BoW-centroids
L2
0.545
0.545
0.682
0.506
0.784
0.516
0.619
0.397
Cosine
0.534
0.534
0.739
0.509
0.841
0.520
0.617
0.354
χ2
0.511
0.511
0.716
0.510
0.830
0.525
0.622
0.352
Hellinger
0.500
0.500
0.716
0.505
0.830
0.519
0.616
0.344
Table 1: Full retrieval comparison on the Genizah join-retrieval benchmark. Methods are grouped into pooling baselines, shared-vocabulary BoW baselines (BoW-RawPatches: global codebook over raw component embeddings; BoW-centroids: global codebook over page-level BoB prototypes), and page-adaptive BoB distances. Higher is better for all metrics. Boldface indicates the best value per column.
Method
Intra
Inter
Gap
KS
AUC
Cohen’s d
BoW-Cosine
0.347
0.617
0.270
0.641
0.899
1.897
BoB-Hungarian-L2
1.735
2.078
0.343
0.665
0.902
1.831
Table 2: Distance-separation statistics for intra-cluster vs. inter-cluster pairs. Larger mean gap, KS statistic, and AUC separation indicate stronger distributional separation.
K
Hit@1
mAP@1
Hit@5
mAP@5
MRR
MF1@1
8
0.648
0.648
0.818
0.600
0.739
0.541
16
0.705
0.705
0.841
0.650
0.767
0.569
20
0.705
0.705
0.864
0.665
0.771
0.580
32
0.773
0.773
0.864
0.689
0.813
0.647
64
0.705
0.705
0.830
0.658
0.770
0.599
Table 3: Ablation on local vocabulary size K for BoB-Hungarian-L2 ( d=128 , sparsity enabled). (MF1 = MacroF1)
d
Hit@1
mAP@1
Hit@5
mAP@5
MRR
MF1@1
64
0.705
0.705
0.807
0.642
0.756
0.578
128
0.773
0.773
0.864
0.689
0.813
0.647
256
0.648
0.648
0.807
0.604
0.719
0.546
Table 4: Ablation on latent dimension d (K=32, sparsity enabled).
Sparsity
Hit@1
mAP@1
Hit@5
mAP@5
MRR
MF1@1
On
0.773
0.773
0.864
0.689
0.813
0.647
Off
0.761
0.761
0.841
0.672
0.805
0.595
Table 5: Ablation on ℓ1 sparsity regularization for BoB-Hungarian-L2 ( K=32 , d=128 ).
Method
Hit@1
mAP@1
Hit@5
mAP@5
MRR
MF1@1
Preserved
0.739
0.739
0.841
0.671
0.789
0.592
Stretched
0.716
0.716
0.830
0.652
0.778
0.603
Table 6: Ablation on component patch normalization for BoB-Hungarian-L2. Preserved : aspect-ratio-preserving scale-and-pad. Stretched : direct isotropic resize to 64×64 .
Method
ms/query
Scales w/ N
BoW-Cosine (precomputed)
0.006
No
BoB-Hungarian (precomputed)
0.006
No
BoB-Hungarian (on-the-fly)
10.30
Yes
BoW-Cosine → BoB-OT ( M =30)
11.33
No
Table 7: Query-time runtime profiling. Precomputed lookup is free for all methods; on-the-fly assignment costs scale with K .