Embedding similarity
Embedding similarity is a comparison of item vectors under a stated representation and similarity or distance rule.
On this page 8 sections
01An encoder maps each item to a vector, its embedding#
An encoder maps each item to a vector, its embedding. A ranking compares these vectors with a chosen rule. These invented cosine scores put A first because its score is largest.
One encoder gives cosine scores A: 0.4, B: 0.8, C: 0.1. Which ranks first?
Show answer and explanation
Choose the largest cosine, 0.8.
02Euclidean distance uses the opposite order: smaller is nearer#
Euclidean distance uses the opposite order: smaller is nearer. A distance of 0.3 ranks ahead of 0.7. Read the metric before sorting; a distance and a cosine score use different scales.
One encoder gives distances A: 0.7, B: 0.2, C: 0.5. Which is nearest?
Show answer and explanation
The smallest distance is 0.2.
03A toy encoder counts words and discards their order#
A toy encoder counts words and discards their order. “A follows B” and “B follows A” get the same vector despite making different claims. A vector match reflects what the representation keeps.
A learner treats cosine 0.94 as proof of truth. What does the score show?
Show answer and explanation
Cosine compares vectors, not factual claims.
04Keep the query, encoder, and metric fixed when reading a ranking#
Keep the query, encoder, and metric fixed when reading a ranking. A different representation can rank the same items differently. Use the top result as a candidate to inspect against the actual task.
A ranking describes a vector match within its representation.
- Interpret a supplied embedding ranking within its stated representation.
Sources & further reading
- [1]Reimers and Gurevych: Sentence-BERT ↗aclanthology.org · Article
- [2]Manning, Raghavan and Schütze: Dot products ↗nlp.stanford.edu · Article