dynavec / Docs / Metrics & rerank

Metrics & rerank

Cosine, dot, euclidean, manhattan, weighted combinations, and MMR.

The S3 Vectors index metric is cosine or euclidean. On top of the returned candidates, dynavec can rescore with any metric — or a weighted combination — client-side.

# single metric
db.search("q", top_k=5, rescore="manhattan")

# weighted combination (normalized per candidate set)
db.search("q", top_k=5, rescore={"cosine": 0.7, "dot": 0.3})

MMR diversity rerank

Maximal Marginal Relevance balances relevance against diversity so results are not near-duplicates.

db.search("q", top_k=5, rerank="mmr", mmr_lambda=0.5)  # 1=relevance, 0=diversity

Both over-fetch top_k * over_fetch candidates first. You can also fuse multiple result lists with Reciprocal Rank Fusion:

from dynavec import reciprocal_rank_fusion
fused = reciprocal_rank_fusion([dense_hits, keyword_hits])