Interface
ISimilarityCalculator

Defines methods for calculating similarity scores between a query and a set of text fragments, enabling retrieval of the most relevant fragments based on semantic similarity.

Definition

Namespace:Telerik.Documents.AI.Core

Assembly:Telerik.Documents.AI.Core.dll

Syntax:

cs-api-definition
public interface ISimilarityCalculator

Derived Classes: DefaultSimilarityCalculator

Methods

CalculateScores(string, IList<Embedding>)

Declaration

cs-api-definition
Task<IList<SimilarityScore<IFragment>>> CalculateScores(string prompt, IList<Embedding> embeddings)

Parameters

prompt

string

The input prompt to compare against the provided fragments. Cannot be null.

embeddings

IList<Embedding>

A list of embeddings representing the fragments to be compared. Cannot be null or empty.

Returns

Task<IList<SimilarityScore<IFragment>>>

A task that represents the asynchronous operation. The task result contains an array of SimilarityScore objects, each representing a fragment and its similarity score. The array will be empty if no fragments are similar.