Challenges
Cosine similarity between embeddings
Artificial Intelligence
Easy
Embedding and similarity
Solves: 7
Cosine similarity between embeddings
Author: CyberSamSU
Points
15
Embedding is the conversion of a word, sentence, or image into a vector of numbers. The most commonly used method to measure how "similar" two embeddings are is cosine similarity: the cosine of the angle between the vectors (independent of their lengths, depending only on their direction).
cos(u, v) = (u . v) / (||u|| * ||v||)
u . v = u1*v1 + u2*v2 + ... (skalyar ko'paytma)
||u|| = sqrt(u1^2 + u2^2 + ...) (Yevklid uzunligi)
Two embedding vectors are given:
u = [0, 3, 5, 5]
v = [4, 5, 2, -4]
Find the cosine similarity between these two vectors.
Answer: only the number, without other characters (for example 0.1234 or -3).
Enter with 4 decimal places of precision (for example -0.1234 or 0.9876).
To submit a flag, log in.