Skip to main content
Interactive 3D/FAISS Index Types: Build, Query, and Memory
FAISS factory string:faiss.index_factory(d, "IVF1000,Flat")
Recall@10
54.8%
Query Time
13.3ms
Build Time
100.0s
Memory
524 MB
QPS
75
IndexIVFFlat
Partitions space into nlist Voronoi cells via k-means. Searches nprobe nearest cells. Trade recall for speed via nprobe.
Use case: Medium scale (1M–100M), when you need exact distances after coarse search
Scale: 1M–100M vectors
Throughput vs Recall - IndexIVFFlat
Higher recall → lower QPS tradeoff0K2K3K0.51.0Recall@10QPS
Controls
Index Type
Dataset Size1M
10K10M
nprobe32
nlist = 1000 (auto). nprobe / nlist = 3% cells searched.
Options
Factory string: FAISS's string API to build indexes. Combine: IVF (coarse), PQ (compression), Flat (exact), HNSW (graph).

Rule of thumb: nlist ≈ √n. Train the index on a subset (≥30×nlist vectors) before adding all vectors.

GPU FAISS: flatly 10-100× QPS over CPU for Flat/IVF. Not supported for HNSW.

FAISS Index Types: Build, Query, and Memory - Interactive Visualization

FAISS (Facebook AI Similarity Search) is the production standard for billion-scale vector search. It provides four primary index types: IndexFlatL2 gives exact results scanning all vectors - perfect recall but O(n) query time, practical only below 1M vectors. IndexIVFFlat partitions vectors into Voronoi cells via k-means and searches only the nprobe nearest cells - recall and speed both controlled by nprobe. IndexIVFPQ adds Product Quantization to compress 128-dimensional float32 vectors (512 bytes each) down to as few as 8 bytes, enabling billion-scale search in memory. IndexHNSWFlat builds a Hierarchical Navigable Small World graph for logarithmic query time with the best recall-speed tradeoff, at the cost of high memory overhead for graph edges. FAISS factory strings are a concise API to compose index types.

  • IndexFlatL2: exact search, 100% recall, O(n) query - benchmarking baseline, not production at scale
  • IndexIVFFlat: train k-means (nlist ≈ √n cells), set nprobe at query time - IVF1024,Flat factory string
  • IndexIVFPQ: Product Quantization compresses 512 bytes → 32 bytes (16x), billion-scale on a single server
  • IndexHNSWFlat: no training needed, log-time search, M=32 links per node, ~99% recall at 1-2ms query
  • GPU acceleration: FAISS-GPU delivers 10-100x QPS for Flat and IVF indexes - not supported for HNSW
  • Factory string API: faiss.index_factory(d, "IVF1024,PQ64x8") composes index types in a single line

Part of the EngineersOfAI Interactive 3D - free interactive visualizations covering every major concept in machine learning and AI engineering. Hover any element for a plain-English explanation. No code required.