

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Semantic Search
incomplete
2: Embeddings
incomplete
3: Embedding Models
incomplete
4: Model Selection
incomplete
5: Vector Operations
incomplete
6: Dimensions
incomplete
7: Dot Product Similarity
incomplete
8: Cosine Similarity
incomplete
9: Why Cosine Similarity?
incomplete
10: Generating Text Embeddings
incomplete
11: Document Embeddings
incomplete
12: Query Embeddings
incomplete
13: Same Model
incomplete
14: Implementing Semantic Search
incomplete
15: Locality-Sensitive Hashing
incomplete
16: Vector Databases
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Vectors are lists of numbers that represent points in space. The interesting part is that semantically similar words have vectors that are close together. That means we need vector math to measure how close two vectors are.
Click to play video
Vector addition is useful for combining concepts. For example: "I want a result that's like this and like that."
With vector addition, we just add the corresponding elements of two vectors together.
[0.5, -0.2, 0.8]
+
[0.1, 0.9, -0.3]
=
[0.6, 0.7, 0.5]
"The Great Bear" embeds to [0.5, -0.2, 0.8] (Animation, Adventure, Family). "Back Country" embeds to [0.1, 0.9, -0.3] (Horror, Thriller, Survival). Add them together and we get [0.6, 0.7, 0.5], a mix of those genres: Family, Adventure, and Horror.
Vector subtraction is useful for removing concepts. For example: "I want a result that's like this but not that."
[0.5, -0.2, 0.8]
-
[0.1, 0.9, -0.3]
=
[0.4, -1.1, 1.1]
"The Great Bear" embeds to [0.5, -0.2, 0.8] (Animation, Adventure, Family). If we subtract "The Revenant," which embeds to [0.1, 0.9, -0.3] (Horror, Thriller, Survival), we get [0.4, -1.1, 1.1], representing Family Adventure but not Horror or Survival.
Implement the add_vectors and subtract_vectors functions.