Multi-Vector Search
Zvec supports multi-vector queries, allowing you to combine different embeddings in a single search.
When querying multiple vector embeddings, Zvec retrieves candidates from each vector space independently and then fuses them into one relevance-ordered list. Because scores from different vector spaces might not be directly comparable, you must choose a suitable re-ranking strategy.
Prerequisites
This guide assumes:
- You have opened a
collectionwith multiple vector fields - You're familiar with the basic vector querying concepts. If not, please review the single-vector search guide
Performing Multi-Vector Search
In Python, pass a list of query specifications to query() and provide a fusion strategy through reranker. In Node.js, pass the sub-queries to multiQuerySync() or multiQuery() and configure rerank.
This example queries both dense_embedding and sparse_embedding and uses WeightedReRanker to combine their results. Weights are positional and must follow the same order as queries.
import zvec
result = collection.query(
topk=3, # Number of final documents returned after re-ranking
queries=[ # List of query specifications β one for each embedding space to search
zvec.Query(field_name="dense_embedding", vector=[0.1] * 768),
zvec.Query(field_name="sparse_embedding", vector={1: 0.1, 37: 0.43}),
],
reranker=zvec.WeightedReRanker(
weights=[1.2, 1.0], # dense_embedding, then sparse_embedding
),
)
print(result)topk always controls the number of final documents returned after fusion.
- Python does not currently expose a separate candidate-count option for each sub-query in
Collection.query(). - Node.js supports
numCandidateson each sub-query. If omitted, its default ismax(topk, 10). topnis used only when calling a re-ranker's standalonererank()method; it is not a constructor argument.
Re-ranking Strategies
Zvec provides different re-ranking strategies to combine scores from multiple vector fields.
| Re-ranker | WeightedReRanker | RrfReRanker (Reciprocal Rank Fusion) |
|---|---|---|
| Approach | Combines normalized similarity scores using custom weights | Fuses results based only on ranking positions β no scores needed With a zero-based rank r (the first result is 0), the RRF score is: |
| Best for | β’ Scores are reasonably comparable across vector fields β’ You know the relative importance of each embedding type | β’ Scores come from different metrics or scales β’ You prefer a simple, robust, tuning-free method |
| Parameters | weights: An ordered list aligned with queries. Score normalization uses each queried field's schema. | rank_constant (k): Controls how quickly rank influence decreases. Higher values reduce the dominance of top-ranked results. |