Product Quantization (PQ) is a vector compression algorithm that splits a high-dimensional embedding vector into M disjoint sub-vectors of equal dimension. Each sub-vector is independently quantized to the nearest centroid in a pre-learned codebook of k codewords, typically using k-means clustering. The original vector is then represented compactly by the M indices of the closest centroids, reducing storage from D * 32 bits to M * log2(k) bits.
Glossary
Product Quantization (PQ)

What is Product Quantization (PQ)?
Product Quantization is a lossy vector compression technique that decomposes the original high-dimensional embedding space into a Cartesian product of lower-dimensional subspaces and quantizes each subspace independently, dramatically reducing memory requirements for billion-scale approximate nearest neighbor (ANN) indices.
During similarity search, the query vector is split identically, and distances to each sub-codebook centroid are pre-computed into lookup tables. The approximate distance between the query and any database vector is reconstructed by summing the pre-computed distances indexed by the stored PQ codes. This asymmetric distance computation (ADC) enables fast, memory-efficient scoring without decompressing the full vectors, making PQ the foundational compression layer in inverted file (IVF) indexing systems like FAISS.
Key Characteristics of Product Quantization
Product Quantization (PQ) decomposes high-dimensional vectors into smaller sub-vectors and quantizes each independently, achieving dramatic memory compression for billion-scale nearest neighbor search.
Subspace Decomposition
The original D-dimensional vector is split into M disjoint sub-vectors of dimension D/M. Each sub-vector is quantized independently using its own codebook of K centroids. This transforms the vector into a compact code of M byte-sized indices, reducing storage from D × 4 bytes to M × 1 byte when K=256.
Asymmetric Distance Computation
During search, the query vector is not quantized—only the database vectors are compressed. The query is split into sub-vectors, and distances to all K centroids in each subspace are precomputed into lookup tables. The approximate distance to any database vector is then assembled by summing M table lookups, avoiding explicit vector reconstruction.
Codebook Training via K-Means
Each subspace requires its own codebook of K centroids, learned independently using K-Means clustering on the sub-vectors of a representative training set. The Lloyd algorithm iteratively refines centroids to minimize quantization error. The product of M codebooks creates an effective vocabulary of K^M possible vectors from only M × K stored centroids.
Memory-Latency Trade-off
PQ enables billion-scale indices to fit entirely in RAM rather than requiring SSD storage. A 128-dimensional float32 vector (512 bytes) compressed with M=64, K=256 becomes just 64 bytes. This 8× compression allows 1 billion vectors to occupy ~64 GB instead of ~512 GB, dramatically reducing infrastructure costs while maintaining acceptable recall.
Optimized Product Quantization (OPQ)
Standard PQ applies an arbitrary axis-aligned split, which may not align with the data's natural correlation structure. OPQ learns an orthogonal rotation matrix applied before subspace decomposition, minimizing quantization distortion by decorrelating dimensions across subspaces. This pre-rotation significantly improves recall at the same bitrate.
Inverted File with PQ (IVFPQ)
PQ is commonly combined with an Inverted File (IVF) index for two-stage retrieval. The IVF partitions the vector space into Voronoi cells using coarse quantization. A query probes the nearest cells, and PQ-compressed vectors within those cells are scored using asymmetric distance computation. This avoids exhaustive scan of the entire database.
Product Quantization vs. Other Compression Techniques
A technical comparison of Product Quantization against alternative vector compression methods for billion-scale approximate nearest neighbor search.
| Feature | Product Quantization | Scalar Quantization | Dimensionality Reduction |
|---|---|---|---|
Compression Mechanism | Splits vector into subvectors and quantizes each independently using codebooks | Reduces bit-width of each scalar dimension (e.g., float32 to int8) | Projects high-dimensional vectors into a lower-dimensional space via PCA or random projection |
Memory Reduction Ratio | 8-16x (e.g., 128-dim float32 from 512B to 32-64B) | 4x (float32 to int8) | 2-10x depending on target dimension |
Distance Computation | Asymmetric Distance Computation (ADC) using precomputed lookup tables | Integer arithmetic with dequantization or direct integer comparison | Full dot product or Euclidean distance in reduced space |
Search Accuracy (Recall@10) | 95-99% with optimal codebook size | 90-95% for int8; degrades sharply below 8 bits | 80-95% depending on retained variance |
Codebook Training Cost | High: requires k-means clustering per subspace on training data | Low: min/max range calibration or percentile clipping | Medium: requires eigendecomposition or matrix factorization |
Encoding Speed | Moderate: O(k * d) per vector for nearest centroid assignment | Fast: simple rounding and clamping operations | Fast: single matrix multiplication |
Inverted File Compatibility | |||
Subspace Independence |
Frequently Asked Questions
Clear, technical answers to the most common questions about Product Quantization and its role in scaling billion-scale vector search.
Product Quantization (PQ) is a vector compression technique that decomposes a high-dimensional embedding space into a Cartesian product of lower-dimensional subspaces and quantizes each subspace independently. The original d-dimensional vector is split into m disjoint sub-vectors of dimension d/m. A separate k-means codebook is learned for each subspace, typically containing 256 centroids. The original vector is then represented as a short code—a sequence of m 8-bit integers—where each integer is the index of the nearest centroid in that subspace's codebook. This reduces storage from d × 32 bits (for float32) to m × 8 bits, achieving compression ratios of 16x to 32x while preserving enough geometric information for approximate distance computation via lookup tables.
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
Product Quantization is a cornerstone of modern ANN search. These related techniques and concepts define the broader landscape of vector compression, indexing, and similarity retrieval at scale.
Inverted File Index (IVF)
A partitioning strategy frequently paired with PQ to form the IVFPQ index. IVF clusters the vector space into Voronoi cells using k-means.
- Coarse Quantizer: The first-stage clustering that narrows the search scope.
- Residual Encoding: PQ compresses the residual vector—the difference between the query and the cluster centroid—for finer discrimination.
- Benefit: Avoids exhaustive scan by probing only the nearest partitions.
Scalar Quantization (SQ)
A simpler compression alternative that maps each continuous vector dimension to a discrete integer, typically converting 32-bit floats to 8-bit integers.
- Uniform Mapping: Applies a scale and offset per dimension.
- Memory Reduction: Achieves a fixed 4x compression ratio.
- Comparison to PQ: SQ is faster to encode but offers significantly lower compression ratios than PQ for the same accuracy loss.
Locality-Sensitive Hashing (LSH)
A hashing-based ANN technique that uses random projection functions to partition space. It contrasts with PQ's quantization approach.
- Hash Collision Principle: Similar vectors have a high probability of landing in the same bucket.
- Trade-off: LSH offers strong theoretical guarantees but often requires more memory than PQ-based indices to achieve comparable recall in high dimensions.
Asymmetric Distance Computation (ADC)
The standard query-time distance estimation method for PQ. The query vector is not quantized; only the database vectors are compressed.
- Lookup Tables: Distances between the query sub-vectors and all centroids are pre-computed.
- Distance Estimation: The approximate distance is assembled by summing lookups, avoiding decompression.
- Advantage: Higher accuracy than symmetric computation where the query is also quantized.
Optimized Product Quantization (OPQ)
An enhancement that learns an orthogonal rotation matrix applied to the vector space before PQ decomposition.
- Variance Balancing: Rotates data to evenly distribute variance across subspaces.
- Quantization Distortion: Minimizes the error introduced by independent subspace quantization.
- Result: Significantly improves search accuracy over vanilla PQ at the same bitrate.

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