Lab
Vector Search Simulator
Watch nearest-neighbour retrieval over an embedded corpus.
Retrieval finds the corpus entries whose vectors sit closest to the query’s. Compare exact search, which scores every vector, against an approximate index that clusters the corpus and only looks inside the nearest cells, faster, but it can miss a true neighbour.
Colour = cluster. Dimmed points are in cells this query did not probe (invisible to IVF). Ringed points are the returned top-3.
- 1.#2 “training a neural network”0.612
- 2.#6 “kittens are playful”0.372
Exact search is a linear scan: score all 14 vectors, sort, take the top k. It is always correct but its cost grows with the corpus. The IVF index clusters vectors once, then at query time ranks the clusters and scans only the nearest nProbe of them, trading a little recall for far fewer comparisons.
Honest note: this is a teaching index (k-means + inverted lists), not a production ANN system like HNSW, and it runs over the toy character-trigram embeddings. The trade-off it demonstrates, recall versus vectors scanned, is exactly the one real vector databases manage.
Challenge
Set the method to IVF with nProbe = 1 and find a query where recall drops below 100%. What does the scatter show about where its true neighbours live? Now raise nProbe until recall returns to 100%, how many clusters did you have to scan?