Class Reranker
- Namespace
- LMKit.Embeddings
- Assembly
- LM-Kit.NET.dll
Computes embedding-based similarity scores and reorders/reranks documents or text partitions based on their relevance to a given query. Useful for selecting the most relevant items from a set by comparing embedding distances or similarity metrics.
public sealed class Reranker
- Inheritance
-
Reranker
- Inherited Members
Constructors
- Reranker(LM)
Initializes a new instance of the Reranker class with the specified embedding-capable language model.
Fields
- NormalizeScore
When
true
, reranking scores will be normalized to a common scale, in the range [0 - 1]. Default value is true.
Properties
- Model
Gets the language model instance used for embedding computations.
Methods
- GetScore(string, TextPartition, CancellationToken)
Computes a similarity score for a single text partition synchronously.
- GetScore(string, IEnumerable<TextPartition>, CancellationToken)
Computes similarity scores for a collection of text partitions synchronously.
- GetScore(string, IEnumerable<string>, CancellationToken)
Computes similarity scores for a collection of documents synchronously.
- GetScore(string, string, CancellationToken)
Computes a similarity score for a single document synchronously.
- GetScoreAsync(string, TextPartition, CancellationToken)
Computes a similarity score for a single text partition asynchronously.
- GetScoreAsync(string, IEnumerable<TextPartition>, CancellationToken)
Computes similarity scores for a collection of text partitions asynchronously.
- GetScoreAsync(string, IEnumerable<string>, CancellationToken)
Computes similarity scores for a collection of documents asynchronously.
- GetScoreAsync(string, string, CancellationToken)
Computes a similarity score for a single document asynchronously.
- Rerank(string, PartitionSimilarity, float, CancellationToken)
Reranks the similarity score of a single PartitionSimilarity synchronously by invoking the reranking model and updating its RerankScore property with the new blended score.
- Rerank(string, IEnumerable<PartitionSimilarity>, float, CancellationToken)
Reranks the similarity scores of multiple PartitionSimilarity instances synchronously by invoking the reranking model and updating each instance’s RerankScore property with its new blended score.
- RerankAsync(string, PartitionSimilarity, float, CancellationToken)
Reranks the similarity score of a single PartitionSimilarity asynchronously and updates its RerankScore property with the new blended score.
- RerankAsync(string, IEnumerable<PartitionSimilarity>, float, CancellationToken)
Reranks the similarity scores of multiple PartitionSimilarity instances asynchronously and updates each instance’s RerankScore property with its new blended score.