JEmbeddings

org.llm4s.javaapi.JEmbeddings
See theJEmbeddings companion class
object JEmbeddings

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def cosineSimilarity(a: Array[Float], b: Array[Float]): Double

The cosine similarity of two vectors: from -1 (opposite) through 0 (unrelated) to 1 (the same direction). Computed in double and kept within -1..1 against rounding.

The cosine similarity of two vectors: from -1 (opposite) through 0 (unrelated) to 1 (the same direction). Computed in double and kept within -1..1 against rounding.

A zero vector has no direction, so its similarity to any vector - another zero vector included - is 0; so is that of two empty arrays. A NaN or infinite component gives NaN unless the other vector is zero.

Attributes

Throws
IllegalArgumentException

when the vectors differ in length, as vectors from two different models may

NullPointerException

when either vector is null