Documentation Index
Fetch the complete documentation index at: https://mintlify.com/alibaba/zvec/llms.txt
Use this file to discover all available pages before exploring further.
Overview
WeightedReRanker combines scores from multiple vector fields using a weighted sum. Each vector field’s relevance score is normalized based on its metric type, then scaled by a user-provided weight. Final scores are summed across fields.
This reranker is specifically designed for multi-vector scenarios where query results from multiple vector fields need to be combined with configurable weights.
Constructor
Parameters
Number of top documents to return after reranking.
Ignored. This parameter exists for API consistency but has no effect.
Distance metric used for score normalization. Supported metrics:
L2, IP (inner product), COSINE. Scores are normalized to [0, 1] range.Weight per vector field. Keys are vector field names, values are weight multipliers. Fields not listed use weight
1.0.Properties
Weight mapping for vector fields.
Distance metric used for score normalization.
Number of top documents to return.
Methods
rerank()
Results per vector field. Keys are vector field names, values are lists of documents.
Re-ranked documents with combined scores in the
score field.Score Normalization
Raw distance/similarity scores are normalized to [0, 1] based on the metric type:L2 (Euclidean Distance)
IP (Inner Product)
COSINE (Cosine Similarity)
Usage Examples
Basic Weighted Search
Dynamic Weight Adjustment
Equal Weights (Uniform Fusion)
How It Works
- Normalize Scores: Convert raw distance/similarity scores to [0, 1] range
- Apply Weights: Multiply normalized scores by field weights
- Sum Scores: For each document, sum weighted scores across all fields
- Rank: Return top
ndocuments by combined score
Example
Given query results with COSINE metric:- doc_A:
(1 - 0.1/2) * 2.0 + (1 - 0.2/2) * 1.0=1.9 + 0.9=2.8 - doc_B:
(1 - 0.3/2) * 2.0=1.7 - doc_C:
(1 - 0.15/2) * 1.0=0.925
When to Use Weighted Reranking
Use WeightedReRanker when:
- Different vector fields have different importance
- You have domain knowledge about field weights
- You need fine-grained control over score combination
- Working with multi-vector hybrid search