Check your understandingStay organized with collectionsSave and categorize content based on your preferences.
Page Summary
Dot product considers both angle and magnitude of vectors, making vectors with larger magnitudes more similar despite the angle between them.
Cosine similarity only considers the angle between vectors, disregarding their magnitudes.
Switching from cosine to dot product for similarity calculation makes popular items (with larger vector magnitudes) more similar to all other items.
Switching back from dot product to cosine similarity normalizes the effect of magnitude, making popular items less biased towards similarity with all other items.
In the image above, if you wantbto be more similar toathan toc, which measure should you pick?
Dot product
Correct! The dot product is proportional to both the cosine and the
lengths of vectors. So even though the cosine is higher for the angle
formed bybandcthan for the angle formed
bybanda, the greater vector length ofamakes the dot product ofaandbgreater than the dot product ofbandc.
Cosine
The cosine depends only on the angle between vectors, and the smaller
angle \(\theta_{bc}\) makes \(\cos(\theta_{bc})\) larger than
\(\cos(\theta_{ab})\).
Euclidean distance
The distance \(\vec{bc}\) is smaller than \(\vec{ab}\), leavingbcloser tocthan toa.
You are calculating similarity for music videos. The length of the
embedding vectors of music videos is proportional to their popularity. You
switch from cosine to dot product to calculate similarity. How does
similarity between music videos change?
Popular videos becomemore similarto all videos in general.
Since the dot product is affected by the lengths of both vectors, the
large vector length of popular videos will make them more similar to all
videos.
Popular videos only becomemore similarto other popular videos.
Recall that the dot product is calculated as \(|a||b|\cos(\theta)\).
Assumingais a popular music video, we know its
embedding length, \(|a|\), is larger than that of unpopular videos.
The larger length increases the
dot product irrespective of the value of \(|b|\). Hence, popular videos
become more similar to all other videos, not just other popular videos.
Popular videos becomeless similarto each other than to
less popular videos.
Since dot product increases with vector length, and popular videos have
high vector length, the similarity measure will increase, not decrease.
No change.
Dot product is affected by vector length. The high vector length of
popular videos will change the (previously cosine) similarity measure.
Given the same setup as the previous question, suppose you switch back
to cosine from dot product. How does similarity between music videos change?
Popular videos becomeless similarto all videos.
Because cosine is not affected by vector length, the large vector
length of popular video embeddings does not contribute to similarity.
Thus, switching to cosine from dot product reduces the similarity
between popular videos and all other videos.
Popular videos becomemore similarto all videos.
Cosine is not affected by the vector lengths, so switching from dot
product will cause the similarities for all popular videos to decrease.
Popular videos becomemore similaronly to each other.
Cosine is not affected by the vector lengths, so switching from dot
product will cause the similarities for all popular videos to decrease.
No change.
Since cosine is not affected by vector length, while dot product is,
switching from dot product to cosine will change similarities.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[],[]]