Token Pooling-Aware Training for Multi-Vector Embedding Models

本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。

Token Pooling-Aware Training for Multi-Vector Embedding Models

Multi-vector embedding models give each query token its own opportunity to find a match in a document. This makes them wonderfully expressive for search, but those document vectors add up quickly. A corpus with millions of documents can contain hundreds of millions of vectors! Token pooling makes these representations smaller by merging similar token vectors. The more aggressively I compress them, however, the easier it becomes to lose something useful.

多向量嵌入模型为每个查询标记提供了寻找文档匹配项的机会。这使得它们在搜索方面表现出极强的表达能力,但这些文档向量会迅速累积。一个包含数百万份文档的语料库可能包含数亿个向量!标记池化(Token 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. In this post, I’ll explain how pooling works, train a model for compressed retrieval with Sentence Transformers, and explore the resulting quality and storage tradeoff. With pool_factor=4, my normally trained model retains 94.6% of its unpooled NanoBEIR nDCG@10, with a 4x reduction in document vectors. Token pooling-aware training raises that retention to 97.8% at the same storage budget! Let’s see how.

池化感知训练(Pooling-aware training)教会编码器在向量合并时保留重要信息,从而帮助你在相同的存储预算下获得更好的检索效果。在这篇文章中,我将解释池化的工作原理,使用 Sentence Transformers 训练一个用于压缩检索的模型,并探讨由此产生的质量与存储权衡。在 pool_factor=4 的设置下,我常规训练的模型保留了其未池化 NanoBEIR nDCG@10 的 94.6%,同时文档向量减少了 4 倍。而标记池化感知训练在相同的存储预算下将这一保留率提高到了 97.8%!让我们看看它是如何实现的。

Why Multi-Vector Retrieval Needs So Many Vectors

A single-vector embedding model compresses an entire document into one vector. Multi-vector models such as ColBERT instead keep a collection of contextual token vectors, allowing different parts of a query to match different parts of a document. For example, a query about a laptop with a long battery life can find evidence about the laptop in one part of a document and battery endurance in another.

单向量嵌入模型将整个文档压缩为一个向量。而像 ColBERT 这样的多向量模型则保留了一组上下文标记向量,允许查询的不同部分与文档的不同部分相匹配。例如,关于长续航笔记本电脑的查询,可以在文档的一部分找到关于笔记本电脑的信息,而在另一部分找到关于电池续航的信息。

Token Pooling

HierarchicalTokenPooling groups similar token embeddings using Ward hierarchical clustering. Starting with one group per token vector, it repeatedly merges the two groups that cause the smallest increase in how spread out the vectors are within their groups. This spread is measured by the sum of squared distances from each vector to its group’s mean, so Ward’s method favors compact groups of similar vectors.

HierarchicalTokenPooling 使用 Ward 分层聚类对相似的标记嵌入进行分组。它从每个标记向量作为一个组开始,重复合并那些导致组内向量离散度增加最小的两个组。这种离散度通过每个向量到其组均值的平方距离之和来衡量,因此 Ward 方法倾向于形成相似向量的紧凑组。

Choosing a Pooling Budget

HierarchicalTokenPooling offers three alternative controls: max_tokens (a maximum of 16 vectors per document), pool_factor (approximately one quarter of each document’s original vectors), and distance_threshold (a shared Ward merge-distance threshold). This distinction matters when document lengths vary. With pool_factor=4, a longer document can retain approximately one quarter of its vectors, allowing its representation to grow with its content.

HierarchicalTokenPooling 提供了三种可选的控制方式:max_tokens(每个文档最多 16 个向量)、pool_factor(每个文档原始向量的约四分之一)以及 distance_threshold(共享的 Ward 合并距离阈值)。当文档长度不同时,这种区别很重要。使用 pool_factor=4 时,较长的文档可以保留大约四分之一的向量,从而使其表示能够随内容增长。

Calibrating Adaptive Pooling

Adaptive pooling uses a shared distance threshold to merge similar embeddings more aggressively while preserving more vectors for documents with distinct content. It can be used with any multi-vector model, including one trained without a pooling-aware objective. Rather than choosing a threshold manually, you can calibrate it for a target average vector count.

自适应池化使用共享的距离阈值来更激进地合并相似的嵌入,同时为内容独特的文档保留更多的向量。它可以用于任何多向量模型,包括那些未经池化感知目标训练的模型。与其手动选择阈值,不如根据目标平均向量计数对其进行校准。