← All questions
Retrieval & EmbeddingsHard· System Design· HNSW· IVF-PQ· Memory Constraints

How do you choose between HNSW and IVF-PQ when scaling...

You must calculate the memory footprint of each approach: HNSW-Flat is far too large, and HNSW-PQ is tight on memory. IVF-PQ is the most memory-efficient, allowing for the corpus growth. While the platform team may prefer HNSW for consistency, the physical memory constraint is the deciding factor. If IVF-PQ cannot meet the recall target, the solution is to scale the hardware rather than shipping a sub-optimal index.

Code playground (Python)