passdrill
AI & LLM Engineering · RAG & Embeddings · Card 004/012 easy

A retrieval system ranks documents by comparing a query vector against every document vector using cosine similarity, rather than the raw, unnormalized dot product between them. What property makes cosine similarity attractive for this purpose?

  1. It is always computationally faster than the dot product or Euclidean distance, no matter how large the vectors are
  2. It converts every embedding into a binary vector first, which speeds up the comparison using bitwise operations
  3. It only works correctly when every vector in the index has exactly the same number of dimensions as every other vector
  4. It measures the angle between two vectors rather than their length, so two embeddings pointing in the same direction score as highly similar even if one vector happens to have a larger magnitude than the other
Next card → Shuffle