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.
Glossary
IVFPQ

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.
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.
Key Features of IVFPQ
IVFPQ combines coarse partitioning with compressed residual storage to deliver high-recall vector search with minimal memory overhead.
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.
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
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.
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.
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.
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.
| Feature | IVFPQ | HNSW | LSH |
|---|---|---|---|
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 |
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.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
IVFPQ is a composite indexing strategy. Mastery requires understanding its constituent parts—the coarse partitioning of IVF and the compression of PQ—as well as the broader ANN landscape it operates within.
Inverted File Index (IVF)
The coarse quantizer that forms the first stage of IVFPQ. IVF partitions the vector space into Voronoi cells using k-means clustering. During a search, the query vector is first assigned to its nearest centroids, and the subsequent fine-grained search is restricted to only those high-probability partitions. This drastically reduces the number of distance computations by ignoring irrelevant regions of the space.
- Role in IVFPQ: Provides the non-exhaustive, partition-based candidate generation.
- Key Parameter:
nprobecontrols how many cells are visited, directly trading off speed for recall.
Product Quantization (PQ)
The compression engine that forms the second stage of IVFPQ. PQ decomposes a high-dimensional vector into smaller subvectors, then quantizes each independently using a distinct codebook. This turns a full-precision vector into a short code, dramatically reducing memory consumption.
- Role in IVFPQ: Compresses the residual vectors (the difference between the original vector and its assigned IVF centroid).
- Distance Computation: Uses Asymmetric Distance Computation (ADC) where the query is not compressed, yielding higher accuracy.
Residual Vector Encoding
The critical bridge between IVF and PQ. A residual vector is calculated by subtracting the coarse centroid (from IVF) from the original vector: r = v - c.
This residual encodes only the local, fine-grained deviation from the cluster center. Because residuals have a much smaller variance than the original vectors, they can be compressed far more effectively by Product Quantization with minimal information loss. This two-level encoding is the core insight behind IVFPQ's efficiency.
Asymmetric Distance Computation (ADC)
The standard distance approximation method used during IVFPQ search. The query vector q remains in full precision, while database vectors are represented by their PQ codes.
The distance between q and a database vector is approximated using pre-computed distance look-up tables between q's subvectors and the PQ codebooks. ADC is preferred over Symmetric Distance Computation (SDC) because it introduces less quantization error, providing a superior recall-speed tradeoff.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us