
Token Pooling-Aware Training for Multi-Vector Embedding Models

Multi-vector embedding models like ColBERT represent each document as many contextual token vectors, allowing different query tokens to match different parts of a document via MaxSim scoring. Storing those vectors is expensive: at 4-bit residual quantization, 200 128-dimensional vectors cost 12.8 KB per document, or 12.8 GB per million documents. HierarchicalTokenPooling compresses the representation by merging similar token vectors into group means, using Ward hierarchical clustering. With pool_factor=4, roughly one quarter of the vectors survive, and longer documents keep proportionally more capacity. The pooler also offers max_tokens caps and a distance_threshold that lets the final vector count vary with embedding geometry. A static threshold can be calibrated on a corpus sample with HierarchicalTokenPooling.calibrate_distance_threshold() to hit a target average vector count.
The central problem is that ordinary multi-vector training never optimizes for compressed representations, so pooling can discard distinctions that matter for retrieval. Pooling-aware training fixes this by wrapping the base retrieval loss in MultiVectorTokenPoolingLoss, which applies the objective to both the original embeddings and pooled variants and averages the losses. In the example, the loss combines unpooled retrieval with a factor-4 pooler using weights 0.5 and 0.5, with CachedMultiVectorMultipleNegativesRankingLoss as the retrieval objective. Because Ward clustering makes discrete merge decisions, HierarchicalTokenPooling uses a straight-through estimator to pass gradients from pooled vectors back to member tokens. The same encoder learns to arrange token embeddings so that useful matches survive merging. The loss reuses computed token embeddings across variants, so adding poolers adds clustering and scoring work but not extra encoder passes. Poolers can also be custom BaseTokenPooling implementations, allowing the training objective to match the deployment representation.
Evaluation used two ModernBERT-base models trained identically on 120,000 MS MARCO triplets, differing only in the loss. On NanoBEIR@13, the pooling-aware model at the trained pool_factor=4 improves mean nDCG@10 from 49.03 to 51.23 while storing 74.8% fewer document vectors than unpooled retrieval, raising score retention from 94.6% to 97.8%. Gains also appear at other pool factors and when inference uses fixed caps or adaptive distance thresholds that were never used during training. For example, at an average of 29.58 vectors per document, adaptive pooling retains 97.3% of the pooling-aware model’s unpooled score while storing 84.7% fewer vectors, versus 93.3% retention for the normally trained model. Unpooled retrieval also improves slightly, from 51.84 to 52.39.
Kernels are optional: use_kernels=True on the model accelerates MaxSim scoring and Ward clustering, with the default clustering kernel described as 30-150x faster than SciPy depending on the setting. Kernel settings are not saved with the model, so they must be re-enabled at inference. For reducing index size, the author recommends considering embedding quantization first, then token pooling with pooling-aware fine-tuning, then Matryoshka truncation to reduce per-token dimensionality; the approaches can be combined, and MultiVectorMatryoshkaLoss can be wrapped with MultiVectorTokenPoolingLoss to train for both. The post includes a complete reproducible example, an evaluation script, and model checkpoints, and builds on prior work by Stefan Josef, Benjamin Clavié, Antoine Chaffin, and Griffin Adams.

