VectorOps
org.llm4s.agent.memory.VectorOps
object VectorOps
Utilities for working with embedding vectors.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
VectorOps.type
Members list
Value members
Concrete methods
Calculate cosine similarity between two vectors.
Calculate cosine similarity between two vectors.
Attributes
- Returns
-
Similarity score between -1.0 and 1.0 (1.0 = identical)
Calculate dot product of two vectors.
Calculate dot product of two vectors.
Attributes
Calculate Euclidean distance between two vectors.
Calculate Euclidean distance between two vectors.
Attributes
- Returns
-
Distance (0.0 = identical)
Normalize a vector to unit length.
Normalize a vector to unit length.
Attributes
def topKBySimilarity[T](query: Array[Float], candidates: Seq[(Array[Float], T)], k: Int): Seq[(T, Double)]
Find the top-K most similar vectors to a query.
Find the top-K most similar vectors to a query.
Value parameters
- candidates
-
List of candidate vectors with associated data
- k
-
Number of results to return
- query
-
The query vector
Attributes
- Returns
-
Top-K candidates sorted by similarity (descending)
In this article