Method RerankAsync
- Namespace
- LMKit.Embeddings
- Assembly
- LM-Kit.NET.dll
RerankAsync(string, PartitionSimilarity, float, CancellationToken)
Reranks the similarity score of a single PartitionSimilarity asynchronously and updates its RerankedScore property with the new blended score.
public Task RerankAsync(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.
Returns
- Task
A
Taskrepresenting the asynchronous reranking operation.
Exceptions
- ArgumentNullException
Thrown if
queryorpartitionSimilarityisnull.
RerankAsync(string, IEnumerable<PartitionSimilarity>, float, CancellationToken)
Reranks the similarity scores of multiple PartitionSimilarity instances asynchronously and updates each instance’s RerankedScore property with its new blended score.
public Task RerankAsync(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.
Returns
- Task
A
Taskrepresenting the asynchronous reranking operation.
Exceptions
- ArgumentNullException
Thrown if
queryisnullorpartitionSimilaritiesisnullor empty.