{"slug": "how-do-you-measure-direction-without-size-getting-in-the-way", "title": "How Do You Measure Direction Without Size Getting in the Way?", "summary": "Cosine similarity measures how alike two vectors are by dividing their dot product by the length of both vectors, cancelling out magnitude and leaving only the angle between them, according to the third installment of a Medium Design Bootcamp series on the math behind AI. The article shows that vectors [2, 2] and [1, 1] yield a cosine similarity of 1, and scaling the second vector to [4, 4] raises the raw dot product from 4 to 16 while cosine similarity stays at exactly 1. The author notes that search engines, recommendation systems, and embedding comparisons rely on cosine similarity rather than the raw dot product when compared vectors do not share the same scale.", "body_md": "After walking through vectors in the [first article](https://medium.com/design-bootcamp/i-am-a-designer-learning-about-ai-how-does-a-single-vector-determine-what-netflix-shows-you-next-8c487abb6358), how they define similarity in space, and then discovering the dot product in the [second article](https://medium.com/design-bootcamp/i-said-distance-equals-similarity-that-was-a-lie-467bbde88047), we found that it points to *direction* instead of *distance* to decide if two vectors are similar or not. For a while, that seemed like enough.\n\nBut diving deeper into the dot product, I found that direction alone isn’t the full story. It’s actually still tangled up with something else: the size of the vectors. So does that mean the dot product isn’t useful? Not exactly; it’s doing the job of finding similarity, but it’s using coordinates that can let magnitude quietly take over and skew the result.\n\n*If you’re new here: this is part 3 of a series walking through the math behind AI, one concept at a time, starting from vectors, then the dot product, and now this. Each article builds on the last. Both part one and two of this series ran on Bootcamp publication.*\n\nWe said earlier that direction is what the dot product is really pointing to. That leads to a real question: does direction alone determine how similar two vectors are? It’s focusing more on direction, so why are we still letting vector size affect the calculation? That’s where cosine similarity comes in.\n\nBefore going deeper into cosine similarity and its math, imagine we have two vectors. If we plot them, we can measure the angle between them directly, and that angle alone tells us how aligned they are, regardless of how long either vector is.\n\nTo define cosine similarity properly: it takes the dot product and divides it by the length of both vectors, which cancels out magnitude and leaves only the angle between them.\n\nWhere:\n\nIn the first plot, we have vector 1 = [2, 2] and vector 2 = [0, 2]. The angle between them is 45°, which gives us cos(45°) = **0.707**.\n\nIn the second, we have vector 1 = [2, 2] and vector 2 = [1, 1], with an angle of 0° between them — same direction, different length. That gives us cos(0°) = **1**.\n\nAnd lastly, vector 1 = [0, 2] and vector 2 = [2, 0], a 90° angle between them, which gives us cos(90°) = **0**.\n\nIf we go deeper into these examples, we find that when two vectors are close and pointing in the same direction, the cosine is close to 1, so they’re similar to each other. And that’s how cosine similarity works: without needing to know the vectors’ size at all, we can know their similarity using the angle alone.\n\nHere’s the part that makes this worth the extra math. Take vector 1 = [2, 2] and vector 2 = [1, 1]; cosine similarity gives us 1, same as above. Now watch what happens if vector 2 gets scaled up to [4, 4] instead, same direction, much bigger size. The raw dot product jumps from 4 all the way to 16. But the cosine similarity? Still exactly 1.\n\nSize changed everything for the dot product and nothing for cosine similarity. That’s the whole point.\n\nNow we see that using cosine similarity makes a real difference when it comes to classifying similarity between vectors, especially when the vectors being compared don’t share the same scale. That’s exactly what search engines, recommendation systems, and embedding comparisons rely on. It’s not the raw dot product they use under the hood; it’s this.\n\nHere’s what surprised me: I expected adding more math to make things more complicated. Instead, cosine similarity works by taking something *away;* it strips out the size of both vectors and keeps only the angle between them. Removing information was what made the comparison clearer, not something lost. That felt backwards at first, but it’s exactly why this version, not the raw dot product, is the one real systems actually use.\n\nSo now we know how to measure pure direction, independent of size. But there’s a question this doesn’t answer yet: how much does one vector actually contribute in the direction of another? Cosine similarity tells you *how alike* two directions are; it doesn’t tell you *how much* one vector projects onto the other. That’s the next thing I want to understand, which is the vector projection.\n\nIf you’re following this series as I figure it out in real time, the next piece picks up exactly where this one left off.\n\n[How Do You Measure Direction Without Size Getting in the Way?](https://pub.towardsai.net/how-do-you-measure-direction-without-size-getting-in-the-way-cb6bcb9be62e) was originally published in [Towards AI](https://pub.towardsai.net) on Medium, where people are continuing the conversation by highlighting and responding to this story.", "url": "https://wpnews.pro/news/how-do-you-measure-direction-without-size-getting-in-the-way", "canonical_source": "https://pub.towardsai.net/how-do-you-measure-direction-without-size-getting-in-the-way-cb6bcb9be62e?source=rss----98111c9905da---4", "published_at": "2026-09-23 07:09:22+00:00", "updated_at": "2026-09-23 07:23:39.845658+00:00", "lang": "en", "topics": ["machine-learning", "artificial-intelligence", "natural-language-processing"], "entities": ["Medium", "Design Bootcamp"], "alternates": {"html": "https://wpnews.pro/news/how-do-you-measure-direction-without-size-getting-in-the-way", "markdown": "https://wpnews.pro/news/how-do-you-measure-direction-without-size-getting-in-the-way.md", "text": "https://wpnews.pro/news/how-do-you-measure-direction-without-size-getting-in-the-way.txt", "jsonld": "https://wpnews.pro/news/how-do-you-measure-direction-without-size-getting-in-the-way.jsonld"}}