← All lessons
0152

Embedding Search

Keyword search finds documents that share your words; embedding search finds documents that share your meaning. Every document is embedded once and stored as a vector; a query is embedded the same way, and the nearest vectors are the results — even with zero words in common, since kitten sits beside cat in the space. At millions of documents, checking every vector is too slow, so vector databases use approximate nearest-neighbour indexes (like HNSW graphs) that jump toward the right neighbourhood, trading a sliver of accuracy for enormous speed. This lookup is the retrieval half of RAG.

Pick a query and watch which documents light up — note the matches share no keywords with it. Raise top-k and see relevance fall as the net widens into neighbouring topics.

top-k2
How to train a puppyBest dry food for catsWhy dogs bark at nightFixing a flat bicycle tyreHow to patch drywallReplacing a laptop batteryEasy pasta dinner recipesBaking bread without yeastQuick healthy lunch ideasquery

The query never shares a word with its best matches. Both were embedded into the same space, so "kitten will not eat" lands beside the cat-food document meaning is proximity. This nearest-neighbour lookup is exactly the retrieval step inside RAG.

Check yourself

The query says kitten and the best match says cats — no shared word. What made them land near each other in the space?

Go deeper (free): Pinecone — Vector search basics (free guide)

Next: Mixture of Experts