Inferensys

Glossary

Product Quantization (PQ)

Product Quantization is a vector compression technique that decomposes high-dimensional vectors into smaller sub-vectors and quantizes them independently to dramatically reduce 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 high-dimensional vectors into smaller sub-vectors and quantizes them independently to dramatically reduce memory footprint while preserving approximate similarity search fidelity.

Product Quantization (PQ) is a lossy compression method that splits a high-dimensional vector into M distinct sub-vectors of equal dimension. Each sub-vector is independently quantized by mapping it to the nearest centroid in a pre-computed codebook, typically learned via k-means clustering. The original vector is then represented compactly as a short code of M centroid IDs, reducing storage from floating-point precision to a few bits per sub-vector.

During similarity search, the query vector is similarly decomposed, and distances are computed efficiently using pre-calculated lookup tables of partial distances between query sub-vectors and codebook centroids. This asymmetric distance computation avoids reconstructing the full vectors, enabling billion-scale Approximate Nearest Neighbor (ANN) search entirely in RAM. Libraries like FAISS implement optimized PQ indexes, making it foundational for scalable dense retrieval systems.

VECTOR COMPRESSION FUNDAMENTALS

Key Characteristics of Product Quantization

Product Quantization (PQ) is a lossy compression technique that decomposes high-dimensional vectors into smaller sub-vectors and quantizes them independently, dramatically reducing memory footprint for billion-scale similarity search.

01

Sub-Vector Decomposition

The core mechanism of PQ involves splitting a D-dimensional vector into M distinct sub-vectors of dimension D/M. Each sub-vector is then independently quantized using its own codebook. This decomposition transforms the exponential storage problem of quantizing a single high-dimensional space into a linear combination of smaller, manageable quantization problems, enabling efficient approximate distance computation.

02

Codebook Learning via K-Means

Each sub-space is quantized by learning a codebook of k centroids using the K-Means clustering algorithm on a training set of sub-vectors. The result is M distinct codebooks, each containing k reproduction values. A full vector is then represented not by its original floating-point values, but by a short code composed of the indices of the nearest centroids in each sub-space.

03

Asymmetric Distance Computation (ADC)

To perform efficient similarity search, PQ employs Asymmetric Distance Computation. The query vector is not quantized; only the database vectors are compressed. The distance between a query and a database vector is approximated by summing the squared distances between the query's sub-vectors and the corresponding centroids indexed by the database code. This avoids the additional quantization error that would be introduced by compressing the query.

04

Memory Footprint Reduction

PQ achieves extreme compression. A standard 1024-dimensional float32 vector requires 4096 bytes. Using PQ with M=64 sub-vectors and k=256 centroids, each sub-vector index requires only 8 bits (1 byte). The total storage per vector collapses to just 64 bytes—a 64x reduction. This allows billion-scale vector indexes to reside entirely in RAM, eliminating costly disk I/O during search.

05

Lookup Table Acceleration

Distance computation is accelerated by pre-calculating a distance lookup table for each query. For a given query, the distance from each of its M sub-vectors to all k centroids in the corresponding codebook is computed once. The approximate distance to any database vector is then simply the sum of M pre-computed table lookups, reducing the complexity from O(D) to O(M) per distance calculation.

06

Optimized Product Quantization (OPQ)

A core limitation of standard PQ is that the arbitrary axis-aligned sub-space decomposition may not align with the data's natural distribution. Optimized Product Quantization addresses this by learning an orthogonal rotation matrix applied to the data before splitting. This rotation minimizes quantization distortion by aligning the principal components of the data with the sub-space boundaries, significantly improving recall for the same compression ratio.

VECTOR COMPRESSION COMPARISON

Product Quantization vs. Other Compression Techniques

A technical comparison of Product Quantization against other common vector compression and dimensionality reduction techniques used in high-scale similarity search.

FeatureProduct Quantization (PQ)Scalar Quantization (SQ)Principal Component Analysis (PCA)

Core Mechanism

Sub-vector decomposition and independent codebook clustering

Uniform mapping of float values to integer bins

Linear projection onto principal components

Memory Reduction Factor

8x-32x

2x-4x

2x-10x

Preserves Full Dimensionality

Distance Computation

Asymmetric Distance Computation (ADC) via lookup tables

Integer arithmetic in compressed domain

Full float dot product on reduced dimensions

Training Complexity

Moderate (k-means per sub-space)

Low (min/max range calculation)

Moderate (covariance matrix eigendecomposition)

Search Accuracy Loss

Low to Moderate (tunable)

Low

Moderate (variance loss)

Typical Use Case

Billion-scale ANN indexes

General-purpose model compression

Pre-processing for visualization or noise reduction

VECTOR COMPRESSION

Frequently Asked Questions

Clear, technical answers to the most common questions about Product Quantization and its role in high-scale vector search infrastructure.

Product Quantization (PQ) is a vector compression technique that decomposes a high-dimensional vector into smaller sub-vectors, quantizes each sub-vector independently using a distinct codebook, and represents the original vector as a compact sequence of codebook indices. The process works in three stages: first, the original D-dimensional vector is split into M sub-vectors of dimension D/M. Second, k-means clustering is run independently on each subspace to generate M codebooks, each containing K centroid vectors. Third, the original vector is encoded by finding the nearest centroid in each subspace and storing only the M integer indices. This reduces storage from D * 32 bits to M * log2(K) bits, enabling billion-scale vector indexes to reside entirely in RAM. At query time, distances are computed efficiently using pre-calculated lookup tables that store the distance between the query sub-vector and every centroid in each codebook.

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.