Table of Contents

Interface IRetrievalStrategy

Namespace
LMKit.Retrieval
Assembly
LM-Kit.NET.dll

Defines a strategy for retrieving matching partitions from indexed data sources.

public interface IRetrievalStrategy

Examples

// Assign a retrieval strategy to a RagEngine instance.
LM embeddingModel = LM.LoadFromModelID("embeddinggemma-300m");
RagEngine ragEngine = new RagEngine(embeddingModel);

// Use the default vector (semantic) strategy.
ragEngine.RetrievalStrategy = new VectorRetrievalStrategy();

// Switch to hybrid (vector + keyword) retrieval.
ragEngine.RetrievalStrategy = new HybridRetrievalStrategy();

Remarks

Implementations control how candidate partitions are scored and selected during the initial retrieval phase. Post-retrieval processing such as reranking and MMR diversity filtering is applied by RagEngine regardless of which strategy is used.

LM-Kit provides three built-in strategies: VectorRetrievalStrategy (semantic similarity), Bm25RetrievalStrategy (keyword matching), and HybridRetrievalStrategy (combined with Reciprocal Rank Fusion).

Properties

RequiresQueryVector

Gets a value indicating whether the strategy requires a query embedding vector.

Methods

RetrieveAsync(IReadOnlyList<DataSource>, string, float[], int, float, bool, bool, DataFilter, CancellationToken)

Retrieves matching partitions from the given data sources.

See Also

Share