Inferensys

Glossary

Product Quantization (PQ)

A vector compression technique that decomposes high-dimensional embeddings into smaller sub-vectors and quantizes each independently, drastically reducing the memory footprint of a semantic cache.
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 embeddings into smaller sub-vectors and quantizes each independently, drastically reducing the memory footprint of a semantic cache.

Product Quantization (PQ) is a lossy compression method that splits a high-dimensional vector into distinct sub-vectors, then clusters each subspace independently using k-means to generate a codebook of centroids. The original vector is approximated by the concatenation of the nearest centroid IDs from each subspace, trading a small amount of recall for massive memory savings.

In a sovereign semantic cache, PQ enables storing millions of compressed embeddings entirely in RAM on local infrastructure, avoiding external API calls. The technique reduces storage from 4 bytes per float32 dimension to mere bytes per sub-vector ID, making on-premises approximate nearest neighbor search feasible without specialized hardware.

VECTOR COMPRESSION FUNDAMENTALS

Key Characteristics of Product Quantization

Product Quantization (PQ) is a lossy compression technique that decomposes high-dimensional vectors into orthogonal sub-vectors and quantizes each independently, achieving dramatic memory reduction at the cost of controlled reconstruction error. It is the foundational algorithm enabling billion-scale semantic caches to fit within sovereign memory constraints.

01

Sub-Vector Decomposition

The core mechanism of PQ involves splitting a D-dimensional original vector into M distinct sub-vectors of dimension D/M. Each sub-vector is treated as an independent statistical entity. This decomposition breaks the exponential complexity of quantizing a single high-dimensional space into a manageable linear combination of smaller codebooks. For example, a 128-dimensional embedding is typically split into 8 sub-vectors of 16 dimensions each, allowing each sub-space to be clustered independently using k-means.

02

Independent Codebook Learning

For each of the M sub-spaces, a distinct codebook of k centroids is learned offline using k-means clustering on a representative training dataset. A typical configuration uses 256 centroids per sub-space, requiring only 8 bits per sub-vector index. The final compressed representation of a vector is not the original floating-point values, but a short tuple of M integer indices—one per sub-codebook. This tuple is the PQ code, and its storage cost is M × log2(k) bits.

03

Asymmetric Distance Computation (ADC)

To perform a similarity search without decompressing the database vectors, PQ employs Asymmetric Distance Computation. The query vector remains in full floating-point precision and is split into sub-vectors. The distance from each query sub-vector to every centroid in the corresponding codebook is pre-computed and stored in a lookup table. The approximate distance to any compressed database vector is then reconstructed by summing the pre-computed distances indexed by its PQ code. This avoids expensive on-the-fly decompression.

04

Memory Footprint Reduction

PQ achieves compression ratios that make sovereign semantic caches economically viable. A standard 128-dimensional float32 vector requires 512 bytes of storage. With PQ using M=8 sub-vectors and k=256 centroids, the compressed representation requires only 8 bytes—a 64x reduction. For a cache of 1 billion embeddings, this reduces the storage requirement from 512 GB to just 8 GB, fitting entirely within the RAM of a single on-premises node.

64x
Typical Compression Ratio
8 bytes
Per-Vector Storage (M=8, k=256)
05

Quantization Error and Recall Trade-off

PQ is a lossy compression method. The reconstruction error is directly proportional to the variance within each sub-space cluster. Increasing the number of sub-vectors M or the number of centroids k reduces distortion but increases the code size. In practice, PQ is used for Approximate Nearest Neighbor (ANN) search, not exact search. A slight loss in recall (e.g., 95% recall@10) is traded for a massive gain in speed and memory efficiency. Optimized Product Quantization (OPQ) pre-rotates the data to minimize quantization distortion.

06

Inverted File with PQ (IVFPQ)

For billion-scale datasets, a brute-force scan of PQ codes is still too slow. IVFPQ combines an inverted index with Product Quantization. The vector space is first partitioned into Voronoi cells using a coarse quantizer. A query only visits the nearest cells. Within each cell, the residual vectors (the difference between the original vector and the coarse centroid) are compressed using PQ. This two-level quantization drastically reduces the search scope while maintaining high recall.

VECTOR COMPRESSION

Frequently Asked Questions

Clear, technical answers to the most common questions about Product Quantization and its role in reducing the memory footprint of high-dimensional vector indices for sovereign semantic caches.

Product Quantization (PQ) is a vector compression technique that decomposes a high-dimensional vector into multiple lower-dimensional sub-vectors and quantizes each independently using a distinct codebook. The original vector is then represented by a short code composed of the indices of the nearest centroids in each subspace. This process drastically reduces memory usage because the full-precision floating-point vector is replaced by a compact sequence of integer indices. During search, distances are computed using pre-calculated lookup tables, enabling fast approximate nearest neighbor retrieval without decompressing the entire dataset. PQ is fundamental to scaling semantic caches and vector databases to billions of embeddings.

VECTOR COMPRESSION COMPARISON

Product Quantization vs. Other Compression Techniques

A technical comparison of Product Quantization against alternative vector compression methods for optimizing memory footprint and retrieval speed in sovereign semantic caches.

FeatureProduct Quantization (PQ)Scalar Quantization (SQ)Dimensionality Reduction (PCA)

Compression Mechanism

Sub-vector decomposition and independent codebook clustering

Uniform bit-width reduction per dimension (e.g., float32 to int8)

Linear projection to a lower-dimensional subspace

Memory Footprint Reduction

90-97% (e.g., 4096-dim float32 to 64 bytes)

75% (e.g., float32 to int8)

Variable (depends on target dimensions, typically 50-90%)

Distance Computation Method

Asymmetric Distance Computation (ADC) via lookup tables

Standard distance metrics on quantized values

Standard distance metrics in reduced space

Preserves Full Dimensionality

Approximate Nearest Neighbor Compatible

Encoding Speed

Slow (requires k-means clustering per sub-space)

Fast (simple bit truncation)

Moderate (requires matrix decomposition)

Query-Time Overhead

Low (pre-computed distance lookup tables)

Negligible

Low (projection matrix multiplication)

Typical Recall@10 vs. Brute Force

95-99% with optimal parameters

99-100% (lossless if no overflow)

80-95% (information loss from discarded dimensions)

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.