Table of Contents

Method RetrieveAsync

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

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

Retrieves matching partitions from the given data sources.

public Task<List<PartitionSimilarity>> RetrieveAsync(IReadOnlyList<DataSource> dataSources, string queryText, float[] queryVector, int topK, float minScore, bool forceUniqueDataSource, bool forceUniqueSection, DataFilter filter, CancellationToken cancellationToken)

Parameters

dataSources IReadOnlyList<DataSource>

The data sources to search.

queryText string

The raw query text.

queryVector float[]

The query embedding vector, or null if RequiresQueryVector is false.

topK int

The maximum number of candidate results to return.

minScore float

The minimum similarity score threshold.

forceUniqueDataSource bool

When true, restricts results to the single most relevant data source.

forceUniqueSection bool

When true, restricts results to the single most relevant section.

filter DataFilter

An optional filter to exclude specific data sources or sections.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<List<PartitionSimilarity>>

A list of PartitionSimilarity objects representing the top matching partitions.

Examples

// Typically called internally by RagEngine, but can be invoked directly
// for advanced scenarios.
IRetrievalStrategy strategy = new VectorRetrievalStrategy();

List<PartitionSimilarity> results = await strategy.RetrieveAsync(
    dataSources: ragEngine.DataSources,
    queryText: "How does authentication work?",
    queryVector: embeddingVector,
    topK: 10,
    minScore: 0.3f,
    forceUniqueDataSource: false,
    forceUniqueSection: false,
    filter: null,
    cancellationToken: CancellationToken.None);
Share