Storage Bottleneck of Multi-Vector Embeddings
Single vector embedding models compress the entire document into a single vector, but multi-vector models like ColBERT retain contextual vectors for each token in the document. This allows different parts of the query to match different segments of the document, enhancing search expressiveness, but the number of vectors increases exponentially. In a corpus of millions of documents, hundreds of millions of vectors can arise, leading to storage costs that are difficult to manage.
The original text illustrates this burden with specific figures. In a 4-bit residual quantization (Fast-PLAID) environment, 200 vectors per document at 128 dimensions require 12.8 KB per document, which amounts to 12.8 GB for 1 million documents. Reducing the number of vectors per document to 50 brings it down to 3.2 GB, a 75% reduction. However, simply discarding vectors results in the loss of subtle distinguishing information necessary for search.
| Condition | Vectors per Document | Storage per Document (4-bit Quantization) | Total for 1 Million Documents |
|---|---|---|---|
| Uncompressed (Original) | 200 | 12.8 KB | 12.8 GB |
| Pooling Applied (pool_factor=4) | 50 | 3.2 KB | 3.2 GB |
Token Pooling: Vector Compression via Hierarchical Clustering
HierarchicalTokenPooling uses Ward hierarchical clustering to group similar token embeddings. Initially, each token vector is its own group, and the two groups that increase the sum of squared distances (variance) the least from the average within the group are merged iteratively. This method prefers compact groups where vectors are dense.
The merging process creates a hierarchy, allowing users to select a level that fits their budget to adjust the compression rate. Ultimately, the average vector of each group is calculated and renormalized for use in MaxSim score calculations.
There are three methods for controlling pooling budgets:
- pool_factor: Maintains the number of vectors as an inverse ratio of document length. With `pool_factor=4`, approximately one-fourth of the original vectors are retained, allowing longer documents to have more capacity.
- distance_threshold: Merges groups if the distance between them is below a threshold. Documents with diverse content retain more vectors.
- target_vectors: Fixes the target number of vectors per document.
By default, the first token (usually `[CLS]` etc.) is protected from merging, and pooling is applied only to document embeddings, while query embeddings retain the original.
Pooling-Aware Training: Learning Representations that Withstand Compression
Applying pooling post hoc to standard multi-vector models can result in the loss of subtle distinctions important for search during the merging process. The original training objective did not consider compressed representations. To address this, Pooling-Aware Training was introduced.
The principle is similar to Matryoshka Embeddings. Just as Matryoshka applies search loss to multiple embedding dimension prefixes to make smaller dimensions useful, Pooling-Aware Training applies search loss to representations with reduced token vectors.
For each training batch, two losses are computed and weighted averaged:
$$ \mathcal{L} = \tfrac{1}{2}\mathcal{L}_{\mathrm{unpooled}} + \tfrac{1}{2}\mathcal{L}_{\mathrm{pooled}} $$
- $\mathcal{L}_{\mathrm{unpooled}}$: Loss from searching with the original document embedding
- $\mathcal{L}_{\mathrm{pooled}}$: Loss from searching with the pooled document embedding
Since both losses update the same encoder, the model learns to batch token embeddings to maintain search performance before and after pooling.
- Generate Original Document Embedding
- Apply Pooling Compression
- Calculate Non-Pooling Loss
- Calculate Pooling Loss
- Weighted Sum Backpropagation
- Update Encoder
Ward clustering makes discrete merging decisions, so gradients do not flow. During training, a Straight-Through Estimator is used to pass the gradient of the pooled vector directly to the member tokens, while the cluster assignment itself is not differentiated.
Sentence Transformers Implementation Wrapper
Hugging Face has wrapped this in the `MultiVectorTokenPoolingLoss` class. Users can simply add the pooling module to existing pipelines like `ColBERTLoss`. Optionally, Kernel Acceleration can be activated to increase training speed.
Experimental Results: Trade-off Between Quality Retention and Storage Savings
The original text evaluated quality using the nDCG@10 metric of the NanoBEIR benchmark. Results were compared under the condition of `pool_factor=4` (one-fourth vector compression).
| Standard Model | 94.6 |
| Pooling-Aware Training Model | 97.8 |
- Standard Model + Post-Pooling: Maintained 94.6% of non-pooling baseline performance
- Pooling-Aware Training Model + Pooling: Maintained 97.8% of non-pooling baseline performance
Pooling-Aware Training recovered about 60% of the performance drop (5.4%p) due to compression (3.2%p improvement). It minimized search quality loss within the same storage budget (3.2 GB/1 million documents).
Adaptive Pooling and Practical Application Guide
Instead of a fixed `pool_factor`, using Adaptive Pooling allows for dynamic adjustment of the number of vectors based on document content diversity. By inputting representative document samples (`calibration_documents`) and specifying a target average number of vectors (e.g., 16), it automatically adjusts the `distance_threshold`. This threshold can be reused during indexing.
In practice, pooling can be combined with other compression techniques:
- Residual Quantization + Pooling
- Dimensionality Reduction + Pooling
- Pruning + Pooling
The original text emphasizes that "Pooling-Aware Training can be applied to any multi-vector model and can also be used as a post-correction for models trained without pooling."
"Pooling-aware training teaches the encoder to preserve the information that matters when its vectors are merged, helping you retrieve better from the same storage budget."
Implications for Developers and Remaining Challenges
This technique is a lever that directly reduces the operating costs of RAG systems. If vector DB storage costs and memory usage can be reduced to one-fourth while maintaining search quality at around 98%, the infrastructure budget savings for large-scale services would be significant. A wrapper that can be used immediately in the Sentence Transformers ecosystem lowers the barrier to adoption.
However, the original text only presented results from the small NanoBEIR benchmark. Generalization performance in the full BEIR or domain-specific large-scale corpora, heuristics for automatically determining the optimal `pool_factor` based on document length, domain, and language, and the clustering quality in non-English contexts like Korean require further validation.