Math & Machine Learning

Cosine Similarity Calculator

Compare two texts or numeric vectors, compute cosine similarity, and interpret similarity as both a raw score and percentage.

Cosine Similarity (−1 to 1) Similarity Percentage Dot Product & Magnitudes

Cosine Similarity Mode & Input Selection

How cosine similarity compares numeric vectors

Cosine similarity measures the angle between two nonzero vectors rather than the absolute size of their values. For vectors a and b, the result is their dot product divided by the product of their Euclidean lengths. A value of 1 means identical direction, 0 indicates orthogonality, and −1 indicates opposite direction when signed values are allowed.

For a simple example, vectors (1, 0) and (0, 1) have cosine similarity 0, while (2, 0) and (5, 0) have similarity 1 despite their different magnitudes. Both vectors must have matching dimensions for the pairwise operation to be valid. A zero vector has no defined direction, so cosine similarity is undefined in that case and should not be presented as a reliable score.

Text-embedding comparisons use the same general geometry, but the interpretation depends on the embedding model, preprocessing, and benchmark. A numerically high cosine score is not automatically proof of semantic equivalence, factual agreement, or an appropriate recommendation; thresholds should be calibrated on representative examples.