

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
We need to convert user queries into vectors, just like we did with our documents. That way we can compare the query to the documents. For example, say we have these vectors in our document vector store:
[1,2,3][4,5,6][7,8,9]Which one is closest to the query "bear"?
... It's impossible to say without first converting "bear" into the same kind of vector. So, "bear" –> [2, 3, 4] (for example).
Now, what's closest to [2, 3, 4]? We can use vector math to find out!
Remember that embedding models handle many preprocessing tasks automatically:
This means we can use minimal preprocessing for queries – just basic cleaning like stripping whitespace.
Implement query embedding functionality that converts user search queries into vectors.
print(f"Query: {query}")
print(f"First 3 dimensions: {embedding[:3]}")
print(f"Shape: {embedding.shape}")
Run and submit the CLI tests.