RAG & Retrieval · Ground answers in evidence

Cosine similarity vs dot product vs Euclidean distance?

MediumsimilarityvectorsindexesUpdated Oct 2026
Quiz this track

Short answer

Cosine compares direction and ignores magnitude; dot product includes magnitude; Euclidean measures straight-line distance. Use whichever the embedding model and index were trained and configured for.

For unit-normalised vectors, cosine similarity and dot product produce the same ranking. Without normalisation they diverge, because dot product rewards larger magnitudes. Euclidean distance is sensitive to both direction and scale. The dangerous case is mixing a model's expected metric with a different index metric.

  • Cosine: good when direction matters and lengths vary.
  • Dot product: common for models trained with inner-product objectives.
  • Euclidean: distances in the same space, sensitive to magnitude.
  • Normalise vectors if the index assumes cosine but the model does not guarantee unit length.
Check the index configuration and the model card together. A mismatch often looks like mediocre retrieval rather than an outright error.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1What happens if you use dot product on unnormalised vectors?
  2. 2Why do some indexes require unit vectors?
  3. 3How would you verify the metric is configured correctly?

Say it in the interview

Cosine measures angle, dot product also includes magnitude, and Euclidean measures distance. If vectors are unit length, cosine and dot product rank the same, but once lengths vary they diverge. I match the metric to what the embedding model was trained for and what the index expects, and I verify normalisation. A mismatch usually shows up as retrieval that is vaguely relevant but never quite right.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live RAG & Retrieval mock interview and get scored feedback on depth, clarity and confidence.