Zvec Logo

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 collection with multiple vector fields
  • You're familiar with the basic vector querying concepts. If not, please review the single-vector search guide


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 numCandidates on each sub-query. If omitted, its default is max(topk, 10).
  • topn is used only when calling a re-ranker's standalone rerank() method; it is not a constructor argument.

Re-ranking Strategies

Zvec provides different re-ranking strategies to combine scores from multiple vector fields.

Re-rankerWeightedReRankerRrfReRanker (Reciprocal Rank Fusion)
ApproachCombines normalized similarity scores using custom weightsFuses results based only on ranking positions β€” no scores needed
With a zero-based rank r (the first result is 0), the RRF score is: RRF(r)=1k+r+1\text{RRF}(r) = \frac{1}{k + r + 1}
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
Parametersweights: 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.

On this page