Understand how machines "understand" meaning through numbers. Master Embeddings, Cosine Similarity, and Vector Databases.
Before we query, we must understand how data is stored as high-dimensional vectors.
(Click to reveal)
A process that converts text (or images) into a long list of numbers (a vector).
Example:
"Cat" -> [0.1, 0.5, -0.2...]
(Click to reveal)
Searching by meaning rather than exact word match.
Querying "furry pet" finds "cat" and "dog" even if the words don't match.
(Click to reveal)
A math formula to calculate how similar two vectors are.
Close to 1 = Very Similar
Close to 0 = Unrelated
(Click to reveal)
The length of the vector list.
OpenAI's `text-embedding-3-small` has 1536 dimensions. More dimensions = more nuance captured.
In a vector database, concepts with similar meanings are stored close together physically in the vector space.
Click on the points (King, Apple, etc.) to see how semantic clusters form.
Notice how King and Queen are very close together.
In vector math, you can actually do algebra:
King - Man + Woman ≈ Queen
These words share dimensions related to "Human", "Ruler", and "Person".
Apple and Banana are far away from "King", but close to each other.
If you searched for "Healthy Snack", a vector database would calculate the distance and find these points first, while ignoring "King".
These words share dimensions related to "Food", "Plant", and "Sweet".
The most common use case for Vector DBs today is RAG.
Test your understanding of Vector Databases.
1. What is an "Embedding"?
2. Why is "Cosine Similarity" important?
3. Which of these is a popular Vector Database?