Distance metrics versus similarity algorithms versus vector search
First, let’s distinguish the difference between distance metrics, similarity algorithms, and vector search. A similarity algorithm can use different distance metrics, whereas a vector search can use different similarity algorithms. They are all different concepts that ultimately form the retrieval component of your RAG system. It is important to make the distinction between these concepts serving different purposes if you are going to understand how to properly implement and optimize your retrieval solution. You can think of this as a hierarchy, as shown in Figure 8.1:
Figure 8.1 – Vector store, similarity algorithm, and distance metric hierarchy for two options each
In Figure 8.1, we are only demonstrating two options for each, where each vector search has two different options for similarity algorithms, and then each similarity algorithm has two different options for distance...