Vector Search: Exact, IVF, HNSW and Smaller Vectors
Search a million vectors fast: exact search first, then IVF and HNSW built by hand, smaller vectors, recall measured honestly, and filters.
Phase 2 turned text into vectors. This phase answers the next question: how do you find the closest vectors quickly? You start with the honest, exact answer (compare the question with every vector) and count what it costs. Then you build the two ideas that real vector databases use to avoid that cost, IVF (search only the nearest clusters) and HNSW (walk a graph of neighbours), at a size where every number can be followed by hand.
Both ideas are approximate: they sometimes miss a true neighbour. So the phase teaches the skill that matters most in practice, measuring recall against the exact answer, and turning one knob at a time (nprobe, efSearch, efConstruction, M) while reading the curve. You also shrink vectors with quantisation, and meet the awkward case of searching only one user's documents.
Every algorithm is written by hand in Python, Java and JavaScript on small seeded data, so all three languages print the same numbers. The build topic puts a vector index behind AskDocs, and the playbook gives you a benchmark harness and a test for the question beginners skip: do I even need an index?
Practise this phase
Hands-on exercises: write the code, run it, and press Check to have it tested automatically.