Inferensys

Glossary

IVFPQ

A composite indexing strategy combining an Inverted File Index for coarse partitioning with Product Quantization for compressed residual vector storage, balancing high recall with low memory consumption.
Wide-angle shot of a modern WeWork open floor plan with creative walls covered in AI system architecture diagrams, product team collaborating in standing desk area with industrial lighting.
INDEXING STRATEGY

What is IVFPQ?

A composite indexing strategy combining an Inverted File Index for coarse partitioning with Product Quantization for compressed residual vector storage, balancing high recall with low memory consumption.

IVFPQ is a two-level vector indexing strategy that combines an Inverted File Index (IVF) for coarse space partitioning with Product Quantization (PQ) for compressing the fine-grained residual vectors. The IVF structure first clusters the vector space into Voronoi cells using a coarse quantizer, restricting the search to a small number of the most promising partitions. The residual vectors—the difference between the original vector and its assigned coarse centroid—are then compressed using PQ, which decomposes them into subvectors and quantizes each independently using a distinct codebook.

This architecture dramatically reduces both search latency and memory footprint compared to a flat index. During query time, the asymmetric distance computation (ADC) approximates distances by keeping the query vector in full precision while using the compressed PQ codes for database vectors, yielding higher accuracy than symmetric methods. IVFPQ is the default index in FAISS for billion-scale datasets where storing full-precision vectors in RAM is infeasible, offering a tunable tradeoff between recall, speed, and storage via the number of IVF probes and PQ subvector dimensions.

INDEX ARCHITECTURE

Key Features of IVFPQ

IVFPQ combines coarse partitioning with compressed residual storage to deliver high-recall vector search with minimal memory overhead.

01

Two-Level Index Structure

IVFPQ operates as a composite index with two distinct stages. The first level uses an Inverted File Index (IVF) to partition the vector space into Voronoi cells via a coarse quantizer. The second level applies Product Quantization (PQ) to compress the residual vectors—the difference between the original vector and its assigned coarse centroid. This two-level design restricts expensive distance computations to only the most promising partitions while storing vectors in a highly compressed form.

02

Residual Vector Compression

Rather than quantizing raw vectors directly, IVFPQ compresses residual vectors—the offset from each vector to its cluster centroid. This approach is more efficient because residuals typically have lower variance and energy than the original vectors, allowing the PQ codebook to represent them with less distortion. The process:

  • Compute the coarse centroid for each vector's assigned partition
  • Subtract the centroid to obtain the residual
  • Apply product quantization to the residual
  • Store only the compact PQ codes
03

Asymmetric Distance Computation

IVFPQ employs Asymmetric Distance Computation (ADC) during search to maximize accuracy. The query vector remains in full precision while database vectors are stored as compressed PQ codes. Distance tables are precomputed between the query subvectors and each PQ codebook, enabling fast lookup-based distance approximation. This asymmetry yields significantly higher recall than symmetric approaches where both query and database vectors are quantized.

04

Memory-Recall Tradeoff

IVFPQ offers fine-grained control over the memory-accuracy tradeoff through two primary parameters:

  • nprobe: The number of IVF cells to search during query time. Higher values increase recall but add latency
  • PQ subvector count (M): More subvectors mean finer quantization and higher accuracy, but larger codes

A typical configuration compresses 128-dimensional float32 vectors from 512 bytes down to just 8-64 bytes, achieving 90%+ recall@10 while reducing memory by 8-64x.

8-64x
Memory Reduction
90%+
Recall@10
06

Training and Index Construction

Building an IVFPQ index involves a multi-stage training process:

  • Stage 1: Train the coarse quantizer (typically k-means) on a representative sample to partition the space into cells
  • Stage 2: Assign all training vectors to their nearest coarse centroids and compute residuals
  • Stage 3: Train the product quantizer on the pooled residuals to learn subvector codebooks
  • Stage 4: Encode all database vectors as (coarse ID, PQ code) pairs

This training overhead makes IVFPQ best suited for static or slowly-changing datasets where the index is built once and queried many times.

INDEXING STRATEGY COMPARISON

IVFPQ vs. Other ANN Indexing Strategies

A feature-level comparison of IVFPQ against other common approximate nearest neighbor indexing strategies for high-dimensional vector search.

FeatureIVFPQHNSWLSH

Index Structure

Two-level: IVF coarse partition + PQ residual compression

Multi-layer proximity graph with navigable small-world edges

Hash tables using locality-sensitive hash functions

Memory Footprint

Very low (compressed codes)

High (full vectors + graph edges)

Moderate (hash tables + full vectors)

Query Speed

Fast (restricted candidate set + fast ADC)

Very fast (logarithmic graph traversal)

Fast (hash bucket lookup)

Recall@10 (typical)

0.90-0.98

0.95-0.99

0.80-0.95

Supports Incremental Insertion

Supports Data Compression

Build Time

Moderate (clustering + codebook training)

Moderate (graph construction)

Fast (hash function computation)

Suitable for Billion-Scale

IVFPQ DEEP DIVE

Frequently Asked Questions

Explore the mechanics of the Inverted File with Product Quantization (IVFPQ) index, a foundational technique for compressing and searching billion-scale vector datasets with minimal memory overhead.

IVFPQ is a composite indexing strategy that combines an Inverted File Index (IVF) for coarse partitioning with Product Quantization (PQ) for compressed residual vector storage. It works in two stages: first, a coarse quantizer (typically k-means) partitions the vector space into Voronoi cells, assigning each database vector to its nearest centroid. Second, instead of storing the full-precision vector, the algorithm calculates the residual vector (the difference between the original vector and its assigned centroid) and compresses it using Product Quantization. During search, the query vector is assigned to the nearest coarse centroids, and distances to database vectors within those partitions are approximated using efficient Asymmetric Distance Computation (ADC) on the PQ codes. This dramatically reduces memory consumption—often by 10-30x—while maintaining high recall by focusing computation only on the most promising regions of the space.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.