

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
Checking every single vector in our dataset for every query is really slow. Locality Sensitive Hashing (LSH) offers a clever solution: pre-group similar vectors into "buckets" using a special hash function. Then, when we search for similar vectors, we check only those in the same bucket.
LSH is a tradeoff: it speeds up searches but can miss some similar vectors. In ML terms, you get lower recall. Use LSH when speed matters more than perfect accuracy.
For example, assume we have an LSH hash function called lsh_hash. It might group the following movies like this:
lsh_hash(jungle_book_vec) # bucket A
lsh_hash(indiana_jones_vec) # bucket A
lsh_hash(tarzan_vec) # bucket A
lsh_hash(holy_grail_vec) # bucket B
lsh_hash(life_of_brian_vec) # bucket B