Vector

@Serializable
data class Vector(val values: List<Double>)(source)

Represents a vector of floating-point values. Used for storing embeddings of text.

Constructors

Link copied to clipboard
constructor(values: List<Double>)

Properties

Link copied to clipboard

Returns the dimension (size) of the vector.

Link copied to clipboard

The floating-point values that make up the vector.

Functions

Link copied to clipboard

Calculates the cosine similarity between this vector and another vector. The result is a value between -1 and 1, where 1 means the vectors are identical, 0 means they are orthogonal, and -1 means they are completely opposite.

Link copied to clipboard
infix fun dotProduct(other: Vector): Double
Link copied to clipboard

Calculates the Euclidean distance between this vector and another vector. The result is a non-negative value, where 0 means the vectors are identical.

Link copied to clipboard
Link copied to clipboard