VolatileMemoryStore.GetNearestMatchesAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Retrieves the nearest matches to the given embedding in the specified collection.
public System.Collections.Generic.IAsyncEnumerable<(Microsoft.SemanticKernel.Memory.MemoryRecord, double)> GetNearestMatchesAsync (string collectionName, ReadOnlyMemory<float> embedding, int limit, double minRelevanceScore = 0, bool withEmbeddings = false, System.Threading.CancellationToken cancellationToken = default);
abstract member GetNearestMatchesAsync : string * ReadOnlyMemory<single> * int * double * bool * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<ValueTuple<Microsoft.SemanticKernel.Memory.MemoryRecord, double>>
override this.GetNearestMatchesAsync : string * ReadOnlyMemory<single> * int * double * bool * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<ValueTuple<Microsoft.SemanticKernel.Memory.MemoryRecord, double>>
Public Function GetNearestMatchesAsync (collectionName As String, embedding As ReadOnlyMemory(Of Single), limit As Integer, Optional minRelevanceScore As Double = 0, Optional withEmbeddings As Boolean = false, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of ValueTuple(Of MemoryRecord, Double))
Parameters
- collectionName
- String
The name of the collection to search.
- embedding
- ReadOnlyMemory<Single>
The embedding to find the nearest matches for.
- limit
- Int32
The maximum number of matches to return.
- minRelevanceScore
- Double
The minimum relevance score for a match to be included in the results.
- withEmbeddings
- Boolean
Whether to include the embeddings in the returned memory records.
- cancellationToken
- CancellationToken
A cancellation token to cancel the operation.
Returns
An asynchronous enumerable of memory records and their relevance scores.