Repaso
EspaƱol

How are embeddings usually compared in semantic search?

Options

  1. By checking that the same words appear in both texts
  2. By sorting the vectors alphabetically
  3. By the length of each text
  4. By the cosine similarity (or dot product) between the vectors: the nearest vectors are the most similar texts (Correct option)

Answer

By the cosine similarity (or dot product) between the vectors: the nearest vectors are the most similar texts

Why

Embeddings are vectors, so "similar" becomes "close". Cosine similarity measures the angle between two vectors; the closer to 1, the more alike the meaning.

When vectors are normalized to length 1, cosine similarity and the dot product give the same ranking.

This is what lets a search for "cheap flights" find a page about "low-cost airlines".

Remember

Nearest vectors = most similar meaning.

Key terms

Practice this question in Repaso