ai-utils.js
Version:
Build AI applications, chatbots, and agents with JavaScript and TypeScript.
12 lines (11 loc) • 358 B
TypeScript
/**
* Calculates the cosine similarity between two vectors. They must have the same length.
*
* @param a The first vector.
* @param b The second vector.
*
* @returns The cosine similarity between the two vectors.
*
* @see https://en.wikipedia.org/wiki/Cosine_similarity
*/
export declare function cosineSimilarity(a: number[], b: number[]): number;