Product Quantization (PQ) is a vector compression technique that decomposes a high-dimensional vector into several lower-dimensional subvectors. Each subvector is independently quantized by mapping it to the nearest centroid in a distinct, pre-trained codebook. The original vector is then stored as a short code—a tuple of centroid indices—reducing storage from floating-point precision to a few bytes per vector.
Glossary
Product Quantization (PQ)

What is Product Quantization (PQ)?
Product Quantization (PQ) is a lossy compression technique that decomposes high-dimensional vectors into smaller subvectors, quantizing each independently using a distinct codebook to dramatically reduce memory footprint and accelerate approximate distance calculations.
Distance computation is performed using Asymmetric Distance Computation (ADC) , where the full-precision query vector is compared against the compressed database codes via pre-computed lookup tables. This avoids decompression overhead. The primary tradeoff is quantization error: the distortion between the original vector and its quantized approximation, which directly impacts search recall.
Key Characteristics of Product Quantization
Product Quantization (PQ) is a lossy compression technique that decomposes high-dimensional vectors into orthogonal subvectors and quantizes each independently. This section details the core mechanisms that enable massive memory reduction and fast approximate distance calculations.
Subspace Decomposition
The fundamental operation that splits a D-dimensional vector into M distinct subvectors of dimension D/M. Each subvector resides in its own orthogonal subspace, allowing independent quantization. This structural assumption—that the joint distribution factorizes across subspaces—is the key to PQ's efficiency, reducing the exponential complexity of full vector quantization to a linear combination of smaller problems.
Independent Codebook Learning
A distinct codebook of k centroids is learned for each of the M subspaces, typically via k-means clustering on the subvector training data. The full vector is then represented by a compact tuple of M centroid indices. With M=8 and k=256, a 128-dimensional float32 vector (512 bytes) compresses to just 8 bytes, achieving a 64x memory reduction.
Asymmetric Distance Computation (ADC)
The standard distance approximation strategy where the query vector is kept in full precision while database vectors are compressed. The query is split into subvectors, and distances to all centroids in each subspace's codebook are precomputed into lookup tables. The approximate distance to any compressed database vector is then assembled by summing M table lookups, avoiding explicit vector reconstruction.
Quantization Error Tradeoff
The distortion introduced by mapping continuous subvectors to discrete centroids. This error is the primary accuracy bottleneck and is controlled by two hyperparameters:
- M (number of subspaces): More subspaces mean shorter codes but coarser quantization per subspace.
- k (codebook size): Larger codebooks reduce error but increase training time and lookup table size. The optimal configuration balances memory footprint against recall degradation for the target application.
Optimized Product Quantization (OPQ)
An enhancement that applies an orthogonal rotation matrix to the original vector space before subspace decomposition. This rotation minimizes the statistical dependence between subspaces, making the factorization assumption more valid. OPQ learns the rotation jointly with the codebooks, significantly reducing quantization error for correlated dimensions without increasing the code length.
Distance Table Lookup Speed
The computational core of PQ search. For a query, M lookup tables of size k are precomputed once. The approximate distance to any database vector requires only M additions—reading precomputed values from each table using the stored centroid indices. This replaces a full D-dimensional float32 distance computation with simple integer-indexed additions, achieving orders-of-magnitude speedups on modern CPUs with SIMD.
Product Quantization vs. Other Compression Techniques
A technical comparison of Product Quantization against scalar quantization and binary quantization for compressing high-dimensional vectors in ANN search.
| Feature | Product Quantization | Scalar Quantization | Binary Quantization |
|---|---|---|---|
Compression Mechanism | Subvector clustering with independent codebooks | Per-dimension value binning | Single-bit threshold per dimension |
Typical Compression Ratio | 8-32x | 2-4x | 32x |
Distance Computation | Asymmetric Distance Computation (ADC) | Integer arithmetic | POPCNT / Hamming distance |
Memory Footprint (128-dim float32) | 16-64 bytes | 128-256 bytes | 16 bytes |
Recall@10 vs. Brute-Force | 95-99% | 99-100% | 80-90% |
Codebook Training Required | |||
Subvector Independence Assumption | |||
Suitable for High-Precision Search |
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.
Frequently Asked Questions
Clear, technical answers to the most common questions about Product Quantization, covering its mechanics, accuracy tradeoffs, and practical implementation in vector search systems.
Product Quantization (PQ) is a vector compression technique that decomposes a high-dimensional vector into several lower-dimensional subvectors and quantizes each independently using a distinct codebook. The process begins by splitting a D-dimensional vector into M subvectors of dimension D/M. A k-means clustering algorithm is then run on each subspace independently, generating M codebooks, each containing K centroids. An original vector is encoded as a short code of M integers, where each integer is the ID of the nearest centroid in that subspace's codebook. During search, distances between a query vector and database vectors are approximated using Asymmetric Distance Computation (ADC), where the query is kept in full precision and distances are precomputed against all centroids, then summed via lookup tables. This reduces memory from D × 32 bits per vector to M × log2(K) bits, often achieving compression ratios of 10-30x while preserving enough information for accurate approximate nearest neighbor search.
Related Terms
Product Quantization does not operate in isolation. It is a core component of a broader ecosystem of compression, indexing, and distance computation techniques that together enable billion-scale vector search on limited hardware.
IVFPQ: The Composite Index
The Inverted File with Product Quantization (IVFPQ) index is the canonical production deployment of PQ. It combines a coarse quantizer (typically IVF) for partitioning the vector space with product quantization for compressing residual vectors within each partition.
- Workflow: A query vector is first assigned to the nearest coarse centroid(s), then ADC is used to score PQ-compressed residuals only within those selected Voronoi cells.
- Memory Profile: A billion-scale index of 128-dimensional vectors can fit in under 64 GB of RAM, compared to 512 GB for raw float32 storage.
- Tradeoff: The coarse quantizer introduces a recall ceiling—true neighbors in unvisited partitions are missed—requiring careful tuning of the
nprobeparameter.
Asymmetric Distance Computation (ADC)
ADC is the standard distance approximation method used with PQ-encoded databases. The query vector remains in full precision, while database vectors are represented by their PQ codes. Distances are computed using a pre-calculated lookup table.
- Mechanism: For each subquantizer, the squared distance between the query subvector and every centroid in that sub-codebook is precomputed. The distance to a database vector is then assembled by summing the appropriate lookup table entries.
- Advantage over SDC: Symmetric Distance Computation quantizes both query and database vectors, introducing error on both sides. ADC halves the quantization error by keeping the query exact.
- Computational Cost: ADC reduces distance computation from O(D) floating-point operations to O(M) table lookups and additions, where M is the number of subvectors.
Codebook Learning via K-Means
The codebooks that define PQ's compression are learned offline using k-means clustering on the training distribution of subvectors. The quality of this clustering directly determines the quantization error and downstream search recall.
- Training Process: The original vector space is decomposed into M independent subspaces. For each subspace, k-means with k (typically 256) centroids is run on the corresponding subvectors from a representative training set.
- Centroid Count: Using k=256 yields 8-bit codes per subvector, aligning perfectly with byte boundaries for efficient storage and SIMD-accelerated lookup.
- Optimized Assignment: FAISS implements efficient k-means variants with mini-batch processing and GPU acceleration to handle training sets with millions of vectors across 96-dimensional subspaces.
Optimized Product Quantization (OPQ)
OPQ is an enhancement to vanilla PQ that learns an orthogonal rotation matrix applied to the vector space before subspace decomposition. This rotation minimizes the quantization distortion by decorrelating dimensions across subvectors.
- Core Insight: Standard PQ assumes subspaces are statistically independent. When dimensions are correlated across subspace boundaries, quantization error increases. OPQ finds a rotation that concentrates variance within subspaces.
- Algorithm: Alternating optimization between the rotation matrix and the codebooks, minimizing the global reconstruction error. This is a non-convex problem solved via iterative Procrustes analysis.
- Practical Impact: OPQ can improve recall@10 by 5-15% at the same compression ratio, or achieve equivalent recall with 2x fewer bytes, making it a default preprocessing step in FAISS for high-accuracy deployments.
Scalar Quantization (SQ)
Scalar Quantization is the simpler precursor to PQ that compresses each dimension independently, mapping continuous floating-point values to discrete integer bins. It serves as a baseline and is often used for the coarse quantizer in IVF indices.
- Mechanism: Each dimension's value range is divided into uniform intervals, and values are stored as 8-bit or 4-bit integers. Reconstruction multiplies the integer by the bin width and adds the minimum offset.
- Comparison to PQ: SQ preserves the original dimensionality structure but offers lower compression ratios. A 128-dimensional float32 vector (512 bytes) becomes 128 bytes with 8-bit SQ, versus 16 bytes with 8-bit PQ using M=16.
- Use Case: SQ is preferred when the vector dimensions have clear independent semantic meaning and cross-dimensional correlation is low, or when ultra-fast decoding with minimal lookup tables is required.
Residual Vector Encoding
In two-level indexes like IVFPQ, PQ does not compress the original vector but rather the residual vector—the difference between the original vector and its assigned coarse centroid. This residual has significantly lower variance, reducing quantization error.
- Why Residuals: The coarse quantizer captures the global structure. The residual encodes only the local deviation, which is typically concentrated near zero with a tighter distribution, making it easier for PQ codebooks to model accurately.
- Encoding Pipeline:
residual = original_vector - coarse_centroid. This residual is then decomposed into subvectors and quantized using the PQ codebooks trained specifically on residuals. - Search Impact: During ADC, the coarse centroid is added back to the PQ-reconstructed residual before computing the final distance to the query, ensuring the full vector is approximated for accurate scoring.

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