Table of Contents

Class LlmReranker

Namespace
Mythosia.AI.Rag.Reranking
Assembly
Mythosia.AI.Rag.dll

Re-ranker that uses an existing LLM (AIService) to score and reorder search results. Sends a prompt asking the LLM to rate each document's relevance on a 0โ€“10 scale.

public class LlmReranker : IReranker
Inheritance
LlmReranker
Implements
Inherited Members

Constructors

LlmReranker(IAIService)

Creates an LLM-based re-ranker using the provided AI service. The service should be configured (model, temperature, etc.) before passing in. A low temperature (e.g., 0.0โ€“0.2) is recommended for consistent scoring.

public LlmReranker(IAIService aiService)

Parameters

aiService IAIService

The AI service to use for scoring.

Methods

RerankAsync(string, IReadOnlyList<VectorSearchResult>, CancellationToken)

Re-ranks the given search results based on their relevance to the query. Returns all results with updated scores, ordered by relevance (descending).

public Task<IReadOnlyList<VectorSearchResult>> RerankAsync(string query, IReadOnlyList<VectorSearchResult> results, CancellationToken cancellationToken = default)

Parameters

query string

The original text query.

results IReadOnlyList<VectorSearchResult>

The initial retrieval results to re-rank.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<IReadOnlyList<VectorSearchResult>>

All results re-scored and ordered by relevance (descending).