Skip to content

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

Hugging Face 27 min read How-to mediumAdept

Training and Finetuning Multi-Vector Embedding Models with Sentence Transformers

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.

Assumes: embedding modelscontrastive learningPyTorch training basicsretrieval evaluation metrics

Related posts

  • 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.

  • Token Pooling-Aware Training for Multi-Vector Embedding Models

    Hugging Face hardMaster

    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.

  • 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.

  • Training and Finetuning Embedding Models with Sentence Transformers

    Hugging Face mediumAdept

    Sentence Transformers v3 trains and finetunes embedding models through a SentenceTransformerTrainer that combines Hugging Face datasets, a loss function, optional training arguments and evaluators. Finetuning matters because each task needs its own notion of similarity. Dataset column order must match the chosen loss's inputs, with an optional "label" or "score" column, and extraneous columns must be removed. A worked example finetunes MPNet on AllNLI triplets with MultipleNegativesRankingLoss and a no-duplicates batch sampler, and evaluates with TripletEvaluator and EmbeddingSimilarityEvaluator on STSb.

  • Multimodal Embedding & Reranker Models with Sentence Transformers

    Hugging Face mediumAdept

    Sentence Transformers v5.4 extends its familiar encode/similarity and CrossEncoder APIs to images, audio, video and mixed text-image inputs, mapping them into a shared embedding space for cross-modal search, visual document retrieval and multimodal RAG. Code examples show loading VLM-based models such as Qwen3-VL-Embedding-2B, using encode_query/encode_document for prompt-aware retrieval, ranking mixed-modality documents with multimodal rerankers, and combining both in a retrieve-then-rerank pipeline. Cross-modal similarity scores run lower than within-modality scores because of the modality gap, but relative ordering is preserved. VLM models need roughly 8 GB of VRAM for 2B variants and about 20 GB for 8B, while CLIP or text-only models suit CPU inference.

The quest for software engineering knowledge.

Look:
Layout: