CosineSimilarity

public class CosineSimilarity


Utility class for computing cosine similarity between Embedding objects.

Summary

Public methods

static double

Computes cosine similarity between two Embedding objects.

Public methods

compute

public static double compute(Embedding u, Embedding v)

Computes cosine similarity between two Embedding objects.

Throws
java.lang.IllegalArgumentException

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