piapia123
en

Vector Similarity Calculator

Web

Everything runs locally in your browser — nothing is uploaded

Input
Drop a file here to load its contents
Output

One vector per line, and you get all five metrics for every pair: cosine similarity, dot product, Euclidean, Manhattan and Chebyshev distance — all shown together for comparison. They are shown together because they answer two questions that are easily confused: cosine asks "same direction?" (double a vector and cosine is unchanged), Euclidean asks "how far?" (double it and the distance changes). Each vector norm is listed too, and the most similar pair under the metric you choose is called out. ⚠️ Cosine similarity has no meaning when a vector is zero (norm 0); the tool reports an error rather than handing you 0 or NaN. Everything runs locally in your browser.

Features

  • All five metrics at once: cosine, dot, Euclidean, Manhattan, Chebyshev
  • A complete pairwise comparison, one row per pair
  • The norm (L2 length) of every vector
  • The most similar pair under your chosen metric, called out separately
  • ⚠️ Cosine of a zero vector is an error — never 0 or NaN
  • A dimension mismatch names the offending vector
  • Optional normalisation to unit length (cosine unchanged, dot becomes cosine)
  • Adjustable decimal places (0–10)

How to use

  1. Enter one vector per line, separated by commas or spaces
  2. Choose the metric used to pick the most similar pair
  3. Optionally enable normalisation, or change the decimal places
  4. Click Copy to take the result

FAQ

Should I use cosine similarity or Euclidean distance?
It depends on whether you care about direction or magnitude. Cosine looks only at direction: `(1,2,3)` and `(2,4,6)` have cosine 1 (identical direction) even though the second is twice as long. Euclidean distance counts length: the distance between those two points is not 0. Text vectors (term counts, TF-IDF) usually use cosine, since document length should not change whether two documents share a topic.
Why does a zero vector make cosine similarity an error?
Cosine is the dot product divided by the product of the two norms, and the norm of a zero vector is 0, so the division has no answer. Returning 0 would read as "completely dissimilar" and NaN is meaningless. So the tool reports it honestly and names which vector is zero.
Why do the numbers change after normalisation?
Normalisation scales every vector to length 1, discarding magnitude and keeping only direction. Afterwards the dot product equals the cosine similarity, and Euclidean distance relates to cosine by a fixed formula. If you suspect length differences are skewing the comparison, normalise first.
Can vectors of different lengths be compared?
No. All vectors must have the same dimension, or neither the dot product nor the distances are defined. When one line has a different number of values from the first, the tool names that vector rather than padding or truncating it.

Related tools