UNPKG

ai-sdk-ollama

Version:

Vercel AI SDK Provider for Ollama using official ollama-js library

18 lines 692 B
/** * Calculate cosine similarity between two vectors. * * Cosine similarity measures the angle between two vectors in multi-dimensional space, * returning a value between -1 and 1 where: * - 1 means identical direction (most similar) * - 0 means orthogonal (unrelated) * - -1 means opposite direction (least similar) * * For normalized embedding vectors, this is equivalent to the dot product. * * @param a First vector * @param b Second vector * @returns Cosine similarity score between -1 and 1 * @throws Error if vectors have different dimensions */ export declare function cosineSimilarity(a: number[], b: number[]): number; //# sourceMappingURL=cosine-similarity.d.ts.map