Table of Contents

Method FindMatchingPartitionsAsync

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

FindMatchingPartitionsAsync(DataSource, float[], int, float, bool, bool, DataFilter, CancellationToken)

Asynchronously finds the top matching partitions in the given data source based on cosine similarity to the provided query vector.

public static Task<List<PartitionSimilarity>> FindMatchingPartitionsAsync(DataSource dataSource, float[] vector, int topK = 3, float minScore = 0.5, bool forceUniqueDataSource = false, bool forceUniqueSection = false, DataFilter filter = null, CancellationToken cancellationToken = default)

Parameters

dataSource DataSource

A single DataSource to search. Cannot be null.

vector float[]

The query embedding vector as an array of floats.

topK int

The maximum number of top results to return. Defaults to 3; minimum value is 1.

minScore float

The minimum similarity threshold (0 to 0.99). Results with similarity below this value are discarded.

forceUniqueDataSource bool

If true, forces returned matches to come from at most one data source.

forceUniqueSection bool

If true, forces returned matches to come from at most one section per data source.

filter DataFilter

Optional DataFilter to exclude specific data sources or sections.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<List<PartitionSimilarity>>

A task that represents the asynchronous search operation. The task result contains a list of PartitionSimilarity objects representing the top matching partitions, or null if none qualify.

Exceptions

ArgumentNullException

Thrown if dataSource is null.

FindMatchingPartitionsAsync(IEnumerable<DataSource>, float[], int, float, bool, bool, DataFilter, CancellationToken)

Asynchronously finds the top matching partitions from the given data sources based on cosine similarity to the provided query vector.

public static Task<List<PartitionSimilarity>> FindMatchingPartitionsAsync(IEnumerable<DataSource> dataSources, float[] vector, int topK = 3, float minScore = 0.5, bool forceUniqueDataSource = false, bool forceUniqueSection = false, DataFilter filter = null, CancellationToken cancellationToken = default)

Parameters

dataSources IEnumerable<DataSource>

A collection of DataSource instances to search. Cannot be null or empty.

vector float[]

The query embedding vector as an array of floats.

topK int

The maximum number of top results to return. Defaults to 3; minimum value is 1.

minScore float

The minimum similarity threshold (0 to 0.99). Results with similarity below this value are discarded.

forceUniqueDataSource bool

If true, forces returned matches to come from at most one data source.

forceUniqueSection bool

If true, forces returned matches to come from at most one section per data source.

filter DataFilter

Optional DataFilter to exclude specific data sources or sections.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<List<PartitionSimilarity>>

A task that represents the asynchronous search operation. The task result contains a list of PartitionSimilarity objects representing the top matching partitions, or null if none qualify.

Exceptions

ArgumentNullException

Thrown if dataSources is null or contains no elements.