Skip to content
Glacius
Linear algebraConcept reference

Embedding similarity

Embedding similarity is a comparison of item vectors under a stated representation and similarity or distance rule.

On this page 8 sections
  1. Overview
  2. An encoder maps each item to a vector, its embedding
  3. Euclidean distance uses the opposite order: smaller is nearer
  4. A toy encoder counts words and discards their order
  5. Keep the query, encoder, and metric fixed when reading a ranking
  6. Key takeaway
  7. Sources & further reading
  8. Concept connections

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.

Invented cosine scores for one fixed query are A=.92, B=.55, C=.10. Bar heights encode the supplied scores; no coordinates, distances or embedding geometry are inferred.Invented cosine scores for one fixed query are A=.92, B=.55, C=.10. Bar heights encode the supplied scores; no coordinates, distances or embedding geometry are inferred.
Figure 1Invented cosine scores for one fixed query are A=.92, B=.55, C=.10. Bar heights encode the supplied scores; no coordinates, distances or embedding geometry are inferred.
Link to this figure ↗Download SVGDownload PNG
Check your reasoning

One encoder gives cosine scores A: 0.4, B: 0.8, C: 0.1. Which ranks first?

  1. AA
  2. BB
  3. CC
Show answer and explanation
B

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.

Check your reasoning

One encoder gives distances A: 0.7, B: 0.2, C: 0.5. Which is nearest?

  1. AB
  2. BC
  3. CA
Show answer and explanation
B

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.

Check your reasoning

A learner treats cosine 0.94 as proof of truth. What does the score show?

  1. AVerified facts
  2. BIdentical wording
  3. CSimilar directions
Show answer and explanation
Similar directions

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.

Key takeaway

A ranking describes a vector match within its representation.

  • Interpret a supplied embedding ranking within its stated representation.

Sources & further reading

  1. [1]
    Reimers and Gurevych: Sentence-BERTaclanthology.org · Article
  2. [2]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Embedding similarity.” Math behind ML. /learn/la-embedding