autointent.modules.scoring.RerankScorer#
- class autointent.modules.scoring.RerankScorer(embedder_name, k, weights, cross_encoder_name, m=None, rank_threshold_cutoff=None, db_dir=None, embedder_device='cpu', batch_size=32, max_length=None)#
Bases:
autointent.modules.scoring._knn.knn.KNNScorer
Re-ranking scorer using a cross-encoder for intent classification.
This module uses a cross-encoder to re-rank the nearest neighbors retrieved by a KNN scorer.
- Variables:
name – Name of the scorer, defaults to “rerank”.
_scorer – CrossEncoder instance for re-ranking.
- Parameters:
- name = 'rerank'#
- cross_encoder_name#
- m#
- rank_threshold_cutoff = None#
- classmethod from_context(context, k, weights, cross_encoder_name, embedder_name=None, m=None, rank_threshold_cutoff=None)#
Create a RerankScorer instance from a given context.
- Parameters:
context (autointent.context.Context) – Context object containing optimization information and vector index client.
k (int) – Number of closest neighbors to consider during inference.
weights (autointent.custom_types.WEIGHT_TYPES) – Weighting strategy.
cross_encoder_name (str) – Name of the cross-encoder model used for re-ranking.
embedder_name (str | None) – Name of the embedder used for vectorization, or None to use the best existing embedder.
m (int | None) – Number of top-ranked neighbors to consider, or None to use k.
rank_threshold_cutoff (int | None) – Rank threshold cutoff for re-ranking, or None.
- Returns:
An instance of RerankScorer.
- Return type:
- fit(utterances, labels)#
Fit the RerankScorer with utterances and labels.