Vectors
object Vectors
Vector maths shared by SemanticCache and by CacheStore implementations.
kmemo works exclusively with unit-normalized vectors: once a vector has length 1, cosine similarity collapses into a plain dot product, which removes two square roots from every comparison in the search loop. CacheEntry normalizes on construction, so store implementations can safely use dot instead of cosineSimilarity.
Functions
Link copied to clipboard
Link copied to clipboard
Dot product of a and b. Equals the cosine similarity only when both vectors are unit-normalized; use cosineSimilarity when that is not guaranteed.
Link copied to clipboard
Link copied to clipboard
Returns a copy of vector scaled to unit length.