Method Rerank
- Namespace
- LMKit.Embeddings
- Assembly
- LM-Kit.NET.dll
Rerank(string, PartitionSimilarity, float, CancellationToken)
Reranks the similarity score of a single PartitionSimilarity synchronously by invoking the reranking model and updating its RerankedScore property with the new blended score.
public void Rerank(string query, PartitionSimilarity partitionSimilarity, float rerankedAlpha = 0.5, CancellationToken cancellationToken = default)
Parameters
querystringThe input text query used for reranking. Must not be
null.partitionSimilarityPartitionSimilarityThe partition similarity object whose RerankedScore property will be updated. Must not be
null.rerankedAlphafloatA blending factor between the original similarity (top[i]) and the reranker model score (rerank[i]), in the range [0 - 1]. Computed as:
final_score = (α × top[i]) + ((1 − α) × rerank[i])For example, with α = 0.5:
final_score = (0.5 × 0.95) + (0.5 × 0.07) = 0.475 + 0.035 = 0.510A typical default is 0.5 for equal weighting.
cancellationTokenCancellationTokenA token to cancel the operation if needed.
Exceptions
- ArgumentNullException
Thrown if
queryorpartitionSimilarityisnull.
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 RerankedScore property with its new blended score.
public void Rerank(string query, IEnumerable<PartitionSimilarity> partitionSimilarities, float rerankedAlpha = 0.5, CancellationToken cancellationToken = default)
Parameters
querystringThe input text query used for reranking. Must not be
null.partitionSimilaritiesIEnumerable<PartitionSimilarity>A collection of partition similarity objects whose RerankedScore properties will be updated. Must not be
nullor empty.rerankedAlphafloatA blending factor between the original similarity (top[i]) and the reranker model score (rerank[i]), in the range [0 - 1]. Computed as:
final_score = (α × top[i]) + ((1 − α) × rerank[i])For example, with α = 0.5:
final_score = (0.5 × 0.95) + (0.5 × 0.07) = 0.475 + 0.035 = 0.510A typical default is 0.5 for equal weighting.
cancellationTokenCancellationTokenA token to cancel the operation if needed.
Exceptions
- ArgumentNullException
Thrown if
queryisnullorpartitionSimilaritiesisnullor empty.