zvec_db.rerankers.cross_encoder.base
Base class for cross-encoder reranking.
Classes
|
Abstract base class for cross-encoder reranking. |
Mixin to auto-generate properties from private attributes. |
- class zvec_db.rerankers.cross_encoder.base.CrossEncoderPropertyMixin[source]
Mixin to auto-generate properties from private attributes.
Subclasses should define _public_names tuple with attribute names (without underscore prefix) to expose as properties.
- class zvec_db.rerankers.cross_encoder.base.BaseCrossEncoderReranker(query, topn=10, rerank_field=None, fusion_score_weight=1.0)[source]
Abstract base class for cross-encoder reranking.
This class provides the common infrastructure for cross-encoder scoring. Subclasses must implement the _compute_scores_batch() method to define their scoring strategy.
- Parameters:
query (str) – Query for reranking. Required.
topn (int, optional) – Number of top documents to return after reranking. Defaults to 10.
rerank_field (Optional[str], optional) – Document field to use for reranking. If None, uses the entire document content. Defaults to None.
fusion_score_weight (float, optional) –
Weight for blending cross-encoder scores with fusion scores.
Formula: final_score = cross_encoder_score × weight + fusion_score × (1 - weight)
weight = 1.0 → 100% cross-encoder, 0% fusion (pure cross-encoder, default)
weight = 0.8 → 80% cross-encoder, 20% fusion
weight = 0.5 → 50% cross-encoder, 50% fusion
weight = 0.0 → 0% cross-encoder, 100% fusion (pure fusion)
Defaults to 1.0 (pure cross-encoder score).
Note
Subclasses must implement _compute_scores_batch() or _compute_score()
Cross-encoder reranking is more accurate but slower than score fusion
For large document sets, consider using max_batch_size to limit API calls
- property fusion_score_weight: float
Weight for blending cross-encoder scores with fusion scores.
- Type: