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 - Python Tutorial
From the course: Hands-On AI: Introduction to Retrieval-Augmented Generation (RAG)
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
-
-
-
-
Understanding your RAG app with observability2m 31s
-
(Locked)
Begin optimizing your data ingestion1m 6s
-
(Locked)
Different embedding models1m 50s
-
(Locked)
Different ways to compare vectors1m 43s
-
(Locked)
Demo: Adding observability to RAG2m 37s
-
(Locked)
Challenge: Altered data ingestion46s
-
(Locked)
Solution: Altered data ingestion1m 17s
-
(Locked)
Challenge: Different embedding models40s
-
(Locked)
Solution: Different embedding models54s
-
(Locked)
Challenge: Comparing results57s
-
(Locked)
Solution: Comparing results1m 24s
-
-