Table of Contents

Method GetCosineSimilarity

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

GetCosineSimilarity(IList<float>, IList<float>)

Calculates the cosine similarity between two vectors, representing the cosine of the angle between them in a multidimensional space.

public static float GetCosineSimilarity(IList<float> embeddings1, IList<float> embeddings2)

Parameters

embeddings1 IList<float>

The first vector.

embeddings2 IList<float>

The second vector.

Returns

float

The cosine of the angle (or embeddings cosine similarity), in the range [0 ; 1].

Remarks

The higher the cosine similarity value, the closer the proximity of the two texts from which the embedding vectors have been computed.