Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 12 min read Deep dive hardMaster

Token Pooling-Aware Training for Multi-Vector Embedding Models

Pooling-aware training teaches a multi-vector (ColBERT-style) encoder to keep retrieval-relevant information when document token vectors are merged by Ward hierarchical clustering, improving quality at a fixed storage budget. On a ModernBERT-base model trained on 120k MS MARCO triplets, pool_factor=4 retains 94.6% of unpooled NanoBEIR nDCG@10 with ordinary training versus 97.8% with a loss that averages unpooled and pooled retrieval objectives, while cutting document vectors 4x. Sentence Transformers provides HierarchicalTokenPooling (pool_factor, max_tokens or calibrated distance_threshold), a straight-through estimator for gradients through clustering, a MultiVectorTokenPoolingLoss wrapper, and optional CUDA kernels that make Ward clustering 30-150x faster than SciPy.

Assumes: multi-vector retrieval and ColBERTcontrastive embedding trainingMaxSim scoringhierarchical clustering

Related posts

  • Training and Finetuning Multi-Vector Embedding Models with Sentence Transformers

    Hugging Face mediumAdept

    Sentence Transformers v6.0 adds a MultiVectorEncoder model type for ColBERT-style late-interaction retrieval, with a full training stack covering models, datasets, losses, training arguments, evaluators and the trainer. A guide walks through finetuning on MIRIAD medical question-passage pairs. The resulting mLateOn-medical model, trained in 14.5 hours on one RTX 3090, beats every general-purpose dense, sparse, lexical and multi-vector retriever the author tested. Key findings: '-unsupervised' checkpoints taken before supervised finetuning adapt to a new domain better than finished ones, which barely improved or regressed. Lifting the 180–512 token document caps matters too, since truncation cost up to 0.24 NDCG@10 on long passages. A punctuation skiplist shrinks the index by 9.6% with a slight quality gain, and CachedMultiVectorMultipleNegativesRankingLoss allows large effective batch sizes.

  • Multi-Vector (Late Interaction) Embedding Models with Sentence Transformers

    Hugging Face mediumAdept

    Sentence Transformers v6.0 adds MultiVectorEncoder, a fourth model type for ColBERT-style late-interaction retrieval that loads PyLate, Stanford-NLP ColBERT and (with added config) colpali-engine checkpoints. Multi-vector models keep one projected, normalized vector per token and score with MaxSim, summing each query token's best match against document tokens. This preserves exact-match and multi-requirement signals that single-vector models average away, and helps on long documents (mLateOn 77.92 vs mDenseOn 51.59 on MLDR). The cost is index size: 4,874 NQ passages produced 608,414 vectors (311.5 MB float32 vs 7.5 MB for MiniLM), cut to 92 MB with a fast-plaid index and reducible further via token pooling or retrieve-and-rerank. The guide covers loading, separate query and document encoding, scoring, indexing, and visual document retrieval.

  • Train a Sentence Embedding Model with 1B Training Pairs

    Hugging Face hardMaster

    Sentence embedding models trained with a contrastive multiple-negatives ranking loss (InfoNCE) on up to 1 billion sentence pairs, using in-batch negatives, a scaled similarity (C≈20), and cosine vs. dot-product tradeoffs for clustering and ANN search. Batch composition drives quality: larger batches, hard negatives, and batches drawn mostly from one dataset but mixing at least two to learn both local and global topic structure. Training ran on TPU v3-8s with JAX/Flax and produced 20 general-purpose Sentence Transformers models (MiniLM, RoBERTa, DistilBERT, MPNet) reported as state of the art on sentence similarity tasks, plus 8 datasets and a Spaces demo.

  • Matryoshka embeddings: faster OpenAI vector search using Adaptive Retrieval

    Supabase mediumAdept

    OpenAI's text-embedding-3 models are trained with Matryoshka Representation Learning, so an embedding can be shortened by truncating trailing dimensions and renormalizing, which reproduces the API's `dimensions` output. Adaptive Retrieval exploits this with a two-pass search: a fast HNSW-indexed ANN pass on a low-dimensional prefix fetches an oversized shortlist, then exact KNN on the full 3072d vectors re-ranks it. Benchmarks on 1M dbpedia embeddings found a 512d first pass (ef_construction=400, m=32, ef_search=200, limit = top_k × 8) reached 99% accuracy against 3072d KNN at about 580 QPS. By comparison, a single pass on 1536d vectors topped out near 89%. The post finishes with a Postgres/pgvector implementation using a sub_vector SQL function.

  • Training and Finetuning Multimodal Embedding & Reranker Models with Sentence Transformers

    Hugging Face mediumAdept

    Finetuning Qwen3-VL-Embedding-2B with Sentence Transformers for Visual Document Retrieval raised NDCG@10 from 0.888 to 0.947. On the author's evaluation data, that beats every tested VDR model, including models up to 4x larger. The walkthrough covers each training component: loading VLM or Router-composed multimodal models, formatting image/text triplet datasets, CachedMultipleNegativesRankingLoss with mini_batch_size=1 so a batch size of 64 fits in GPU memory via gradient caching, MatryoshkaLoss for truncatable embeddings (near-peak quality at 512 dims), training arguments, and an InformationRetrievalEvaluator built with hard negatives. It also extends the same approach to training multimodal rerankers.

The quest for software engineering knowledge.

Look:
Layout: