utils library
Contains core utilities.
Functions
-
calculateSimilarity(
List< double> embedding, List<List< embeddings, {double similarityFunction(List<double> >double> a, List<double> b) = cosineSimilarity}) → List<double> - Calculates the similarity between an embedding and a list of embeddings.
-
chunkList<
T> (List< T> arr, {required int chunkSize}) → List<List< T> > - Chunk a list into smaller list of a specified size.
-
cosineSimilarity(
List< double> a, List<double> b) → double - Measures the cosine of the angle between two vectors in a vector space. It ranges from -1 to 1, where 1 represents identical vectors, 0 represents orthogonal vectors, and -1 represents vectors that are diametrically opposed.
-
getIndexesMostSimilarEmbeddings(
List< double> embedding, List<List< embeddings, {double similarityFunction(List<double> >double> a, List<double> b) = cosineSimilarity}) → List<int> -
Returns a sorted list of indexes of
embeddings
that are most similar to the providedembedding
(in descending order, most similar first). -
reduce<
Type> (Iterable< Type> input) → Type - Reduces a list of objects to a single object by concatenating them.