Table of Contents

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 RerankScore property with the new blended score.

public Task RerankAsync(string query, PartitionSimilarity partitionSimilarity, float rerankAlpha = 0.5, CancellationToken cancellationToken = default)

Parameters

query string

The input text query used for reranking. Must not be null.

partitionSimilarity PartitionSimilarity

The partition similarity object whose RerankScore property will be updated. Must not be null.

rerankAlpha float

A 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.510

A typical default is 0.5 for equal weighting.

cancellationToken CancellationToken

A token to cancel the operation if needed.

Returns

Task

A Task representing the asynchronous reranking operation.

Exceptions

ArgumentNullException

Thrown if query or partitionSimilarity is null.

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.

public Task RerankAsync(string query, IEnumerable<PartitionSimilarity> partitionSimilarities, float rerankAlpha = 0.5, CancellationToken cancellationToken = default)

Parameters

query string

The input text query used for reranking. Must not be null.

partitionSimilarities IEnumerable<PartitionSimilarity>

A collection of partition similarity objects whose RerankScore properties will be updated. Must not be null or empty.

rerankAlpha float

A 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.510

A typical default is 0.5 for equal weighting.

cancellationToken CancellationToken

A token to cancel the operation if needed.

Returns

Task

A Task representing the asynchronous reranking operation.

Exceptions

ArgumentNullException

Thrown if query is null or partitionSimilarities is null or empty.