Skip to content
Blog

Inner Product vs Cosine Similarity: Why Normalisation Matters

Understand the difference between inner product and cosine similarity, and why normalising your embeddings changes search results.

Published on • November 22, 2026

AI Assistant

Introduction

Inner product and cosine similarity look almost identical — one is literally the other divided by the vector lengths. So why do vector databases list them as separate metrics? The answer is normalisation, and getting it wrong is a common source of “my search quality is weird” bugs.

The Math, Briefly

For vectors a and b:

inner product (IP) = a · b = ||a|| ||b|| cos(θ)
cosine similarity  = (a · b) / (||a|| ||b||) = cos(θ)
  • Cosine strips out both magnitudes and keeps only the angle.
  • Inner product keeps the magnitudes: two long vectors pointing the same way score higher than two short ones pointing the same way.

When the Two Diverge

Consider:

  • a = [1, 0], b = [10, 0] → cosine = 1, inner product = 10
  • a = [1, 0], c = [0.1, 0] → cosine = 1, inner product = 0.1

Cosine ranks b and c as equally aligned with a. Inner product strongly prefers b. If vector length carries no meaning for your use case, that preference is noise.

Why Normalisation Matters

Normalising every vector to unit length (x / ||x||) makes the two metrics equivalent:

  • IP of unit vectors = cosine of the original vectors
  • L2 distance of unit vectors is also a monotonic transform of cosine

So the practical rules are:

  1. Model trained with cosine / normalized embeddings → normalise on write and query, use cosine (or IP — it’s the same ranking).
  2. Model trained with raw inner product (length carries signal) → do not normalise; use IP.
  3. Mixing — indexing normalised vectors but querying with raw ones (or vice versa) — silently breaks ranking.

The Cost of Getting It Wrong

  • Normalising IP-trained vectors destroys the magnitude signal the model encoded → recommendations lose their “popularity” dimension.
  • Using raw IP with a cosine-trained model lets high-norm outliers (often near-duplicates or boilerplate) dominate results.
  • Some databases (e.g., FAISS IndexFlatIP vs IndexFlatIP on normalized data) behave differently only through this choice — same code, different recall.

Practical Checklist

  • Read your embedding model’s card: which metric and whether it L2-normalises.
  • If the model outputs normalised vectors, cosine and IP are interchangeable — pick what your index supports.
  • If unsure, test both on a labelled eval set; recall@10 usually exposes the mismatch immediately.

Conclusion

Cosine similarity answers “do they point the same way?”; inner product answers “do they point the same way, weighted by how big they are?”. Normalisation is the switch between them. Choose the combination your embedding model was trained with, and your rankings will stay honest.

References