Share via


AzureCosmosDBNoSQLMemoryStore.GetNearestMatchesAsync Method

Definition

Gets the nearest matches to an embedding of type Single. Does not guarantee that the collection exists.

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 associated with a collection of embeddings.

embedding
ReadOnlyMemory<Single>

The embedding to compare the collection's embeddings with.

limit
Int32

The maximum number of similarity results to return.

minRelevanceScore
Double

The minimum cosine similarity threshold for returned results.

withEmbeddings
Boolean

If true, the embeddings will be returned in the memory records.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

A group of tuples where item1 is a MemoryRecord and item2 is its similarity score as a Double.

Implements

Applies to