Skip to content
Lesson 4 · Measuring meaning

Similarity = closeness

If similar meanings sit close together, then measuring similarity just means measuring closeness. The most common way is cosine similarity: it looks at the angle between two vectors. Point the same direction and the score is 1 (very similar); point at right angles and it's 0 (unrelated).

Scroll

Angle, not just distance

There are a few ways to measure how close two points are, but the favorite for meaning is the angle between them, called cosine similarity. Why angle? Because it ignores how long each arrow is and focuses on which direction it points. Two sentences about the same topic point the same way, even if one is longer than the other.

How to read a cosine score

  1. Score near 1: the vectors point almost the same direction — nearly the same meaning.
  2. Score near 0: the vectors are at right angles — unrelated.
  3. Score near -1: opposite directions — opposite meaning (rare in practice with text).

Like comparing directions on a compass

Imagine two people pointing. You don't care how far their arms reach — you care whether they're pointing at the same thing. Cosine similarity is exactly that: are these two arrows aimed in the same direction? The closer the aim, the higher the score.

This is the engine of search

Once you can score how similar any two pieces of text are, you can do something powerful: take a question, and find the stored text that scores highest against it. That's semantic search — the next lesson.

InteractiveDrag the angle. Watch the cosine score go from 1 (aligned) to 0 (right angle).
Next: semantic search →