AgentSea.Vector (agentsea_embeddings v0.1.0)

Copy Markdown

Small vector math: dot product, L2 norm, normalization, cosine similarity.

Summary

Functions

Cosine similarity in [-1, 1] (0.0 if either vector is zero).

Scale a vector to unit length (returns it unchanged if it's the zero vector).

Types

t()

@type t() :: [float()]

Functions

cosine(a, b)

@spec cosine(t(), t()) :: float()

Cosine similarity in [-1, 1] (0.0 if either vector is zero).

dot(a, b)

@spec dot(t(), t()) :: float()

norm(vec)

@spec norm(t()) :: float()

normalize(vec)

@spec normalize(t()) :: t()

Scale a vector to unit length (returns it unchanged if it's the zero vector).