cosine similarity

Explore embeddings through the geometry of cosine similarity explained simply

Dot products can feel abstract until you see them from both angles.

3 min readMachine Learning
Explore embeddings through the geometry of cosine similarity explained simply
Great Video for Understanding How Cosine Similarity Works [D]

Many explanations of embeddings treat cosine similarity as a black-box formula, which is a shame because the geometry behind it is genuinely intuitive. This video, shared by user johnolafenwa, does something rare: it walks through the dot product from both an algebraic and a geometric perspective, then uses that foundation to show exactly why cosine similarity measures the angle between vectors, not their magnitude. That clarity matters because embeddings are becoming the backbone of how machines understand text, images, and even legal documents. We think this kind of grounded explanation is exactly what the field needs more of, not hype, but understanding.

The practical payoff is immediate. When you know that cosine similarity is essentially asking "how similar is the direction these two vectors are pointing," you stop treating it as a magic number and start using it as a diagnostic tool. It is the difference between blindly trusting a model's output and being able to debug why a certain document was flagged as a conflict. Our recent piece on Explore how encoder models detect legal document conflicts with open-source precision shows exactly this principle in action: encoder models rely on the same geometric relationships to spot contradictions across thousands of clauses. Without a solid grasp of what cosine similarity actually measures, you are navigating those systems by guesswork.

This is not an abstract math lesson. It is a skill that directly improves your workflow, whether you are building a recommendation engine, automating image classification, or cleaning up messy datasets. Consider a practical scenario from another piece we published, Practical Python for automating four real-world image decisions. If you are scoring product sharpness or cropping shipping labels, you are often comparing feature vectors derived from images. Understanding that cosine similarity ignores magnitude means you can safely compare a low-resolution thumbnail to a high-resolution reference photo without the scale difference distorting your results. That is not a theoretical edge, it is a concrete decision that saves hours of manual tuning.

The one detail to watch closely is the relationship between algebraic and geometric intuition. Most tutorials skip the geometry because it feels harder, but this video proves the opposite: once you see vectors as arrows in space, the math clicks. Our advice is to take the twenty minutes to work through it, then immediately apply the concept to a project you already have open. The question you should be asking is not whether your embeddings are "good enough," but whether you can explain why two items ended up similar or different. If you cannot, the geometry behind cosine similarity is the place to start.

From Machine Learning

This video does a great job of explaining dot products from both algebraic POV and geometric POV, using that to derive cosine similarity and how it applies to embeddings.

Read the original at Machine Learning