learning-it by example

Back to the video

HNSW vs IVF vs Flat: Vector Indexes Tested on 100k Vectors

I searched 100,000 vectors by looking at about 500, and still found nearly every right answer.

Video #49 ยท RAG and vector search

Steps in the video

  1. 0:00 Searching 100,000 vectors by looking at 500
  2. 0:31 The idea
  3. 1:03 Setup
  4. 1:27 A hundred thousand vectors
  5. 1:48 Flat is the answer key
  6. 2:19 IVF and HNSW
  7. 3:24 What this does not show
  8. 4:03 Mistakes to avoid
  9. 4:36 My take and next steps
  10. 5:03 Recap

Files

  • compare.py (42 lines)
  • data.py (13 lines)

Download the code (zip)

Tested with

Python 3.12.15 | faiss-cpu==1.15.0

What this does not show

100,000 made-up clustered vectors of 64 numbers and 200 queries, one seeded run; work is counted in comparisons, not time, and the IVF count leaves out the 316 group comparisons; adding, deleting and filtering were not tested.

Sources

Learning IT by Example.