From the course: Hands-On AI: Introduction to Retrieval-Augmented Generation (RAG)

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Different ways to compare vectors

Different ways to compare vectors

- [Instructor] One last concept to understand for a more complete understanding of RAG is how vectors are compared. There are three main ways to compare vector embeddings, cosine distance, inner product, and Euclidean distance. Cosine distance measures the difference of the angles between vectors in hyperspace. This is typically the most expensive way to measure distance due to it being a higher compute. It's quite popular due to a historical reason. Early NLP papers often used cosine distance on normalized vectors. Inner product is sometimes also referred to as dot product. It measures the projection of one vector onto another. It is the cheapest or least compute expensive of the three-mentioned methods. Euclidean distance measures the actual distance between two points in hyperspace. In terms of cost, it's in the middle of cosine and IP. It makes the most sense to use on normalized vectors, but can also be used on non-normalized vectors. Some quick notes here. Normalized vectors are…

Contents