Skip to content
Quantoros

What are FAISS index types and when do you use each?

NLPLevel: IntermediateAdvanced Indexing

What are FAISS index types and when do you use each?

Hints
  • Separate text representation, modeling and evaluation.
  • Check ambiguity, rare terms and training versus target text distributions.

Answer

FAISS (Facebook AI Similarity Search) is the most widely used ANN library. Index type selection:

IndexDescriptionWhen to UseNotes
IndexFlatL2 / IndexFlatIPExact brute-force search<100K vectors, need perfect recallBaseline; no approximation
IndexIVFFlatIVF with exact cell search1M–10M vectors, moderate recallSet nprobe to tune recall/speed
IndexIVFPQIVF + Product Quantization10M–1B+ vectors, memory-limited16–64× compression; use for scale
IndexHNSWFlatHNSW with full-precision vectors1M–100M, low-latency requirementBest recall/speed tradeoff
IndexHNSWSQHNSW + scalar quantization1M–100M, moderate memory4× compression, ~2% recall loss
IndexScalarQuantizerSQ8 vector storageAny, add to aboveReduce memory 4×

Practical recipe for production:

  • < 500K vectors: IndexFlatL2 (exact is fast enough)
  • 500K–50M: IndexIVFFlat with nlist=sqrt(N), nprobe=20–50
  • 50M+: IndexIVFPQ with M=8 (subspaces), nbits=8 (256 centroids per subspace)

Source and licence: JustInCache & contributors — Awesome AI Interviews · Apache-2.0

Related questions