๐Ÿ“

Cosine Similarity Calculator

Calculate the cosine similarity between two text/feature vectors (up to 6 dimensions). Used in NLP, recommendation systems, and information retrieval.

Results

Cosine Similarity0.928,571
Similarity (%)92.86 %
Angle Between Vectorsโ€”
Dot Product13.0,000

๐Ÿ“–What is it?

Cosine similarity measures the cosine of the angle between two vectors: cos(ฮธ) = (AยทB) / (โ€–Aโ€– ร— โ€–Bโ€–). A value of 1 means identical direction (most similar), 0 means orthogonal (unrelated), and -1 means opposite. It is widely used to measure document similarity in NLP and find related items in recommendation systems because it is magnitude-independent.

๐ŸŽฏHow to use

Enter the numerical values for each dimension of the two vectors. For TF-IDF document comparison, each dimension represents a word and the value is its TF-IDF score. For word embeddings (Word2Vec, GloVe), enter the embedding values.

๐Ÿ’กExample scenario

A = [3, 2, 1], B = [2, 3, 1]. Dot product = 3ร—2 + 2ร—3 + 1ร—1 = 13. โ€–Aโ€– = โˆš14 โ‰ˆ 3.742, โ€–Bโ€– = โˆš14 โ‰ˆ 3.742. Cosine = 13/14 โ‰ˆ 0.929 โ€” the vectors are 92.9% similar.

๐Ÿ†Pro tip

Unlike Euclidean distance, cosine similarity ignores magnitude โ€” a document with 1000 words and the same proportional term distribution as a 100-word document will score equally similar to a query. This is why it is preferred for document length-normalised comparisons.