CosineSimilarity

public class CosineSimilarity

Utility class for computing cosine similarity between Embedding objects.

Public Methods

static double
compute(Embedding u, Embedding v)
Computes cosine similarity between two Embedding objects.

Inherited Methods

Public Methods

public static double compute (Embedding u, Embedding v)

Computes cosine similarity between two Embedding objects.

Parameters
u
v
Throws
IllegalArgumentException if the embeddings are of different types (float vs. quantized), have different sizes, or have an L2-norm of 0.