Inferensys

Glossary

Product Quantization (PQ)

A vector compression technique that decomposes the original embedding space into a Cartesian product of lower-dimensional subspaces and quantizes each separately, dramatically reducing memory requirements for billion-scale ANN indices.
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 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.

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.

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.

VECTOR COMPRESSION

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.

01

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.

8-16×
Typical Compression Ratio
02

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.

O(M × K)
Precomputation Cost
03

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.

K^M
Effective Vocabulary Size
04

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.

64 GB
1B Vectors at 64 bytes
05

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.

06

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.

nprobe
Cells Probed per Query
VECTOR COMPRESSION COMPARISON

Product Quantization vs. Other Compression Techniques

A technical comparison of Product Quantization against alternative vector compression methods for billion-scale approximate nearest neighbor search.

FeatureProduct QuantizationScalar QuantizationDimensionality 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

VECTOR COMPRESSION

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.

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.