Inferensys

Glossary

Product Quantization (PQ)

A vector compression technique that decomposes the original high-dimensional space into a Cartesian product of lower-dimensional subspaces and quantizes each independently, dramatically reducing memory footprint for large-scale similarity search.
Engineer reviewing vector database search results on laptop, embeddings visualization on screen, home office coding session.
VECTOR COMPRESSION

What is Product Quantization (PQ)?

Product Quantization (PQ) is a vector compression technique that decomposes the original high-dimensional space into a Cartesian product of lower-dimensional subspaces and quantizes each independently, dramatically reducing memory footprint for approximate nearest neighbor search.

Product Quantization (PQ) is a lossy compression method for high-dimensional vectors that splits the original vector into M equal sub-vectors. Each sub-vector is independently quantized by mapping it to the nearest centroid in a pre-computed codebook, replacing the original floating-point values with compact integer codes. This process reduces storage from D × 32 bits to M × log₂(K) bits, where K is the number of centroids per subspace.

During similarity search, the query vector is similarly decomposed, and distances are computed using pre-calculated lookup tables that store the distances between the query sub-vectors and each subspace centroid. This asymmetric distance computation avoids reconstructing the original vectors, enabling efficient approximate distance calculations. FAISS and ScaNN implement optimized PQ indexes, making billion-scale vector search feasible on commodity hardware.

VECTOR COMPRESSION MECHANICS

Key Characteristics of Product Quantization

Product Quantization (PQ) is a lossy compression technique that decomposes high-dimensional vectors into orthogonal subspaces and quantizes each independently, enabling massive memory reduction for approximate nearest neighbor search.

01

Subspace Decomposition

The original D-dimensional vector is split into M disjoint subvectors of dimension D/M. Each subvector is quantized independently using its own codebook of k centroids. This transforms the vector into a compact code of M integers, reducing storage from D×32 bits to M×log₂(k) bits. A typical configuration decomposes a 768-dimensional embedding into 96 subvectors of 8 dimensions each.

02

Codebook Learning via K-Means

Each subspace's codebook is trained independently using k-means clustering on the subvectors extracted from a representative training set. The centroids minimize the quantization error within each subspace. After training, any new vector is encoded by finding the nearest centroid in each subspace and storing its index. The full vector is approximated by concatenating the corresponding centroids.

03

Asymmetric Distance Computation (ADC)

During search, PQ uses Asymmetric Distance Computation to avoid reconstructing database vectors. The query vector is split into subvectors, and the distance from each query subvector to every centroid in the corresponding codebook is precomputed into a lookup table. The approximate distance to any database vector is then computed by summing M table lookups, achieving orders-of-magnitude speedup over exact distance calculation.

04

Memory Footprint Reduction

PQ achieves compression ratios of 8× to 16× compared to full-precision float32 vectors. For 1 billion 128-dimensional vectors, raw storage requires 512 GB. With PQ using M=16 subspaces and k=256 centroids, storage drops to 16 GB—a 32× reduction. This enables billion-scale vector indexes to reside entirely in RAM on a single commodity server.

05

Optimized Product Quantization (OPQ)

Standard PQ assumes subspace independence, which may not hold for real data distributions. OPQ applies an orthogonal rotation matrix to the vector space before decomposition, decorrelating dimensions and balancing variance across subspaces. This rotation is learned jointly with the codebooks to minimize overall quantization distortion, typically improving recall by 5-15% at equivalent bitrates.

06

Inverted File with PQ (IVFPQ)

For billion-scale search, PQ is combined with an Inverted File (IVF) index. The IVF partitions the vector space into Voronoi cells using coarse quantization. A query probes only the nearest cells, and PQ compresses the vectors within each cell. This two-level quantization—coarse for pruning, fine for compression—enables sub-millisecond latency on billion-vector datasets while using minimal memory.

VECTOR COMPRESSION COMPARISON

Product Quantization vs. Other Compression Techniques

A technical comparison of Product Quantization against scalar quantization and dimensionality reduction for compressing dense vector embeddings in high-scale semantic search systems.

FeatureProduct QuantizationScalar QuantizationDimensionality Reduction

Compression mechanism

Subspace decomposition and codebook clustering

Reducing bit-width per dimension

Projecting to lower-dimensional space

Memory reduction factor

8-32x

2-4x

2-10x

Preserves original dimensionality

Distance computation method

Asymmetric distance via lookup tables

Integer arithmetic

Full recomputation in reduced space

Training required

Recall@10 on SIFT-1M (approx.)

95-98%

99-100%

85-92%

Search latency impact

Minimal with lookup tables

Negligible

Reduced due to fewer dimensions

Suitable for binary embeddings

VECTOR COMPRESSION

Frequently Asked Questions

Clear, technical answers to the most common questions about Product Quantization (PQ), its mechanisms, and its role in high-performance vector search.

Product Quantization (PQ) is a vector compression technique that decomposes the original high-dimensional vector space into a Cartesian product of lower-dimensional subspaces and quantizes each subspace independently. The process works by first splitting a D-dimensional vector into M distinct sub-vectors of dimension D/M. A k-means clustering algorithm is then run independently on each subspace to generate a codebook of centroids. The original vector is compressed by replacing each sub-vector with the ID of its nearest centroid, reducing storage from D floating-point numbers to M integer codes. During search, distances are computed using asymmetric distance computation (ADC), where the query vector is compared against the stored codes via pre-computed lookup tables, avoiding full vector reconstruction. This enables billion-scale similarity search in memory-constrained environments.

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.