How AI Measures Similarity
How AI Measures Similarity
Imagine you walk into a library containing one million books. You ask the librarian, "Show me books similar to Harry Potter. " How does the librarian decide what similar means? By the colour of the cover? The number of pages? The weight of the book? Probably not. Similarity is far more subtle. Machine Learning faces exactly the same problem. When Netflix recommends a movie... when Spotify suggests a song... when ChatGPT searches for relevant knowledge... the first question is always the same. How similar are these two objects? Now that every object has become a vector, mathematics finally has something it can compare. But before comparing two vectors, we must understand one. Suppose we have the vector (3,4) What is its size? How long is it? How large is it? This idea is called the Norm. Think of the norm as the vector's length. Just as a ruler measures the length of a pencil, the norm measures the length of a vector. A vector without a norm is like a road without a distance marker. You know where it points. You don't know how far it reaches. Now consider two vectors. One represents Student A. The other represents Student B. How far apart are they? If the vectors lie very close together, perhaps the students have similar performance. If they are far apart, their characteristics may be very different. This introduces the idea of Distance. Distance tells us how far two vectors are from one another. It answers the question, "How different are these two objects? " At this point, it seems we've solved the problem. Small distance means similar. Large distance means different. But mathematics notices something strange. Consider these two vectors. (1,2) and (10,20) The second vector is much longer. So the distance between them is quite large. Yet both vectors point in exactly the same direction. One is simply a scaled version of the other. Should we really call them different? Sometimes... yes. Sometimes... no. Imagine two businesses. One earns ₹10 lakh per month. Another earns ₹10 crore per month. Very different sizes. But both grow at exactly the same rate every year. Their behaviour is remarkably similar. Or consider two students. One scores 40, 50, 60. Another scores 80, 100, 120. Different marks. Exactly the same pattern. Sometimes, the pattern matters more than the magnitude. This leads to one of the most elegant ideas in linear algebra. Instead of asking, "How far apart are these vectors? " we ask, "Are they pointing in the same direction? " This idea is called Cosine Similarity. It ignores size. It focuses on orientation. If two vectors point in nearly the same direction, they are considered highly similar, even if one is much larger than the other. This single idea quietly powers modern Artificial Intelligence. When you search the web... AI isn't looking for identical sentences. It looks for vectors pointing in similar directions. When ChatGPT retrieves relevant information... it searches for nearby vectors in an embedding space. When Spotify recommends music... or Netflix recommends films... or your phone recognizes a face... they are all solving the same mathematical problem. Find the vectors that are most similar. What began as a simple question— "How do we compare two objects? " has become one of the most important operations in Artificial Intelligence. Every recommendation. Every semantic search. Every embedding model. Every vector database. Begins by measuring similarity. And to measure similarity, mathematics first gave us three powerful ideas: Norm — How large is a vector? Distance — How far apart are two vectors? Cosine Similarity — How closely do they point in the same direction? These three concepts form the mathematical foundation of almost every modern AI system. We've learned how to represent objects as vectors. We've learned how to compare them. But another mystery remains. A student may be described by five numbers. A customer by fifty. A medical record by five hundred. A language model by thousands. What does it mean to live in a space with hundreds or even thousands of dimensions? That question takes us to the next chapter. Why Dimensions Matter.
