IMemoryStore.GetNearestMatchAsync 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.
Gets the nearest match to an embedding of type Single. Does not guarantee that the collection exists.
public System.Threading.Tasks.Task<(Microsoft.SemanticKernel.Memory.MemoryRecord, double)?> GetNearestMatchAsync (string collectionName, ReadOnlyMemory<float> embedding, double minRelevanceScore = 0, bool withEmbedding = false, System.Threading.CancellationToken cancellationToken = default);
abstract member GetNearestMatchAsync : string * ReadOnlyMemory<single> * double * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Nullable<ValueTuple<Microsoft.SemanticKernel.Memory.MemoryRecord, double>>>
Public Function GetNearestMatchAsync (collectionName As String, embedding As ReadOnlyMemory(Of Single), Optional minRelevanceScore As Double = 0, Optional withEmbedding As Boolean = false, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Nullable(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.
- minRelevanceScore
- Double
The minimum relevance threshold for returned results.
- withEmbedding
- Boolean
If true, the embedding will be returned in the memory record.
- cancellationToken
- CancellationToken
The CancellationToken to monitor for cancellation requests. The default is None.
Returns
A tuple consisting of the MemoryRecord and the similarity score as a Double. Null if no nearest match found.