Ai Engineering 3 min read

How to Run Late Interaction Models in Sentence Transformers 6.0

Learn how to load ColBERT and ColPali multi-vector models using the new MultiVectorEncoder in Sentence Transformers v6.0 for fine-grained document retrieval.

Hugging Face’s release of Sentence Transformers v6.0 introduces native support for multi-vector embedding models. The new MultiVectorEncoder class integrates ColBERT-style late interaction retrieval directly into the library, allowing you to bypass complex deployments for fine-grained search tasks. This tutorial covers how to load these checkpoints, run token-level comparisons using the MaxSim operator, and handle the storage constraints of multi-vector architectures.

Understanding Late Interaction and MaxSim

Traditional dense bi-encoders compress an entire text sequence into a single vector. While efficient, this compression often loses fine-grained, token-level context. Multi-vector models solve this by preserving one vector per token.

When evaluating a query against a document, the models use a Maximum Similarity (MaxSim) operator. This operator calculates the sum of the maximum similarities between every query token and all document tokens. This late interaction approach yields superior out-of-domain generalization and handles complex queries better than standard dense models. It is highly effective for building robust RAG pipelines where precision at the entity or term level is required.

Installation and Requirements

Sentence Transformers v6.0 requires updated dependencies to support the new model class and operators. Your environment must run PyTorch 2.2+, Transformers v5.x, and huggingface-hub v1.x.

bash pip install -U sentence-transformers transformers huggingface-hub torch

Basic Usage with MultiVectorEncoder

Loading a late interaction model uses the standard Sentence Transformers API conventions. You can load checkpoints built for ColBERT, PyLate, or colpali-engine directly. The v6.0 release incorporates work from PyLate, a library developed by LightOn, making models like the mLateOn family (designed for multilingual, long-context, and code retrieval) and GTE-ModernColBERT available through a unified interface.

The MultiVectorEncoder handles MaxSim scoring automatically when comparing query and document arrays. You encode text exactly as you would with single-vector models.

python from sentence_transformers import MultiVectorEncoder

Load a ColBERT or PyLate checkpoint

model = MultiVectorEncoder(“lightonai/LateOn-Code”)

Encode queries and documents

query_embeddings = model.encode(“Which planet is known as the Red Planet?”) docs_embeddings = model.encode([“Mars is the fourth planet.”, “The moon orbits Earth.”])

Scoring via MaxSim is handled natively

scores = model.similarity(query_embeddings, docs_embeddings)

Visual Document Retrieval with ColPali

The update also adds native support for ColPali models. Unlike traditional embeddings that require pre-processing text, ColPali matches text queries directly against document page images at the pixel level. This enables Visual Document Retrieval (VDR) without requiring an intermediate Optical Character Recognition (OCR) step, preserving the spatial and structural context of the original document format.

Storage Tradeoffs and Limitations

Maintaining one vector per token significantly increases memory and storage requirements compared to single-vector models. A standard dense index might require a few kilobytes per document, while a multi-vector index scales linearly with document length.

To keep the index affordable at scale, implement token pooling where possible. You must also select vector databases designed specifically for multi-vector indexing, such as Qdrant or Milvus. Attempting to force multi-vector arrays into standard single-vector stores will result in degraded performance and excessive memory consumption.

Evaluate your existing retrieval metrics against a multi-vector baseline using a subset of your document corpus to measure the recall improvements against the added storage footprint.

Get Insanely Good at AI

Get Insanely Good at AI

The book for developers who want to understand how AI actually works. LLMs, prompt engineering, RAG, AI agents, and production systems.

Keep Reading