What is this? (Explained Simply)
Imagine two people pointing at different stars. Cosine similarity measures the angle between where they point. If both point at the same star — angle is 0, similarity is 1 (perfect match). If they point in perpendicular directions — angle is 90 degrees, similarity is 0 (no relationship). It does not care how far their arms stretch, only the direction they point.
Cosine similarity measures the angle between two vectors, ignoring their magnitude. It outputs a value between -1 (opposite) and +1 (identical direction). This makes it perfect for comparing things where magnitude does not matter — like comparing document topics regardless of document length, or comparing user preferences regardless of how active they are.
Semantic search — When you search "how to cook pasta," the search engine computes cosine similarity between your query embedding and millions of document embeddings.
Plagiarism detection — Turnitin converts documents to TF-IDF vectors and uses cosine similarity to find suspiciously similar papers.
Face recognition — FaceID computes cosine similarity between your face embedding and the stored template. Above 0.9 = unlock.
Music recommendations — Spotify represents songs as feature vectors and recommends songs with high cosine similarity to your favorites.
RAG (Retrieval Augmented Generation) — ChatGPT plugins retrieve relevant documents by cosine similarity between the query and stored chunks.
Duplicate detection — E-commerce platforms detect duplicate product listings by comparing product description embeddings via cosine similarity.
Sentiment analysis — Reviews with similar cosine similarity to known positive/negative templates get classified accordingly.
Gene expression — Bioinformatics uses cosine similarity to find genes with similar expression patterns across experiments.
What would an intelligent skeptic say?
Cosine similarity ignores magnitude, which is sometimes the most important signal. A user who watched 100 action movies and one who watched 2 might have the same cosine similarity to the 'action lover' vector, but their engagement levels are completely different. Also, in very high dimensions, cosine similarities between random vectors converge to 0, making absolute thresholds meaningless without domain-specific calibration.
No community explanations yet. Be the first to share yours!
to write your own explanation
to share your insights
No insights yet. Be the first to share!