Product Quantization (PQ) is a vector compression technique that splits a high-dimensional vector into distinct, lower-dimensional sub-vectors and quantizes each sub-vector independently using a separate codebook. This process drastically reduces the memory footprint required to store large vector datasets by representing the original vector as a compact sequence of codebook indices, enabling efficient approximate nearest neighbor (ANN) search in billion-scale collections.
Glossary
Product Quantization (PQ)

What is Product Quantization (PQ)?
A lossy compression method for high-dimensional vectors that decomposes the original space into a Cartesian product of lower-dimensional subspaces and quantizes each independently.
During similarity search, the query vector is decomposed identically, and distances are computed efficiently using pre-calculated lookup tables between the query sub-vectors and the codebook centroids. This asymmetric distance computation avoids reconstructing the full vectors, trading a small amount of recall accuracy for substantial gains in speed and storage efficiency. PQ is a foundational component in scalable vector databases like FAISS.
Key Features of Product Quantization
Product Quantization (PQ) decomposes high-dimensional vectors into orthogonal sub-vectors and quantizes each independently, achieving massive memory compression while preserving the geometry required for accurate approximate nearest neighbor search.
Sub-Vector Decomposition
The core mechanism of PQ is dimensionality splitting. A D-dimensional vector is divided into M disjoint sub-vectors of dimension D/M. Each sub-vector is then quantized independently using its own codebook of k centroids. This transforms the original vector into a compact tuple of M codebook indices, reducing storage from D×32 bits to M×log₂(k) bits. For a 128-dimensional vector split into 8 sub-vectors with 256 centroids each, the compressed representation requires only 64 bits—a 64× compression ratio.
Codebook Learning via K-Means
Each sub-space requires a codebook—a set of representative centroids learned offline using k-means clustering on a training set of sub-vectors. The process:
- Partition the training vectors into their M constituent sub-vectors
- Run independent k-means on each sub-space to produce k centroids
- Store the M codebooks as the quantization model
The quality of the codebook directly determines search accuracy. Typically, k=256 is used, meaning each sub-vector index fits in a single byte, enabling extremely cache-friendly memory layouts.
Asymmetric Distance Computation
During query time, PQ employs Asymmetric Distance Computation (ADC) to approximate distances without decompressing the database vectors. The query vector is split into sub-vectors, and the exact distance from each query sub-vector to every centroid in the corresponding codebook is pre-computed into a lookup table. For each compressed database vector, the approximate distance is assembled by summing the pre-computed distances indexed by the stored codes. This avoids the costly operation of reconstructing the full vector, achieving sub-linear search complexity.
Memory Footprint Reduction
PQ delivers dramatic memory savings critical for billion-scale vector search. A typical 1024-dimensional float32 vector consumes 4 KB. With PQ using M=64 sub-vectors and k=256 centroids, the compressed representation requires only 64 bytes—a 64× reduction. For 1 billion vectors, this shrinks memory from 4 TB to 62.5 GB, enabling the entire index to reside in RAM on a single high-memory server. This eliminates the latency penalty of disk-based retrieval and makes real-time similarity search economically viable.
Trade-Off: Recall vs. Compression
PQ introduces a tunable accuracy-efficiency trade-off governed by two parameters:
- M (number of sub-vectors): Higher M increases compression but reduces the dimensionality of each sub-space, potentially degrading distance approximation quality
- k (codebook size): Larger k improves quantization fidelity but increases codebook storage and lookup costs
Typical configurations balance M between D/8 and D/2. For exact search, PQ serves as a coarse quantizer in inverted file systems, where candidate vectors are first filtered by a separate IVF index before PQ-based distance refinement. This two-stage approach routinely achieves >95% recall@10 with sub-millisecond latency.
Integration with Inverted File Indexes
PQ is rarely used in isolation for large-scale search. The IVF-PQ architecture combines an Inverted File (IVF) index for coarse partitioning with PQ for fine-grained compression:
- A coarse quantizer partitions the vector space into Voronoi cells
- Each database vector is assigned to its nearest coarse centroid and stored in the corresponding inverted list
- Within each list, vectors are stored in PQ-compressed form
- At query time, only the nprobe nearest coarse centroids are visited, and ADC is applied to the compressed vectors in those lists
This hierarchical approach enables billion-scale ANN search with memory footprints measured in tens of gigabytes.
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 systems.
Product Quantization (PQ) is a vector compression technique that decomposes a high-dimensional vector into multiple lower-dimensional sub-vectors and quantizes each sub-vector independently using a distinct codebook. The original vector is then represented as a short code composed of the indices of the nearest centroids in each subspace. This process drastically reduces the memory footprint of a vector database, enabling billion-scale approximate nearest neighbor (ANN) search to fit entirely in RAM. The core mechanism involves three steps: subspace decomposition, independent clustering via k-means on each subspace, and encoding by concatenating the centroid IDs. During search, distances are computed efficiently using pre-calculated lookup tables, trading a small amount of recall for massive compression ratios, often reducing a 1024-dimensional float32 vector from 4096 bytes to just 64 bytes.
Product Quantization vs. Other Compression Techniques
A technical comparison of Product Quantization against alternative vector compression and dimensionality reduction methods for approximate nearest neighbor search.
| Feature | Product Quantization (PQ) | Scalar Quantization (SQ) | Random Projection |
|---|---|---|---|
Compression Mechanism | Sub-vector decomposition with independent codebook clustering | Uniform bit-width reduction per dimension (e.g., float32 to int8) | Johnson-Lindenstrauss lemma projection onto random lower-dimensional subspace |
Memory Reduction Factor | 8-32x typical (e.g., 128-dim float32 to 64 bytes) | 2-4x typical (e.g., 32-bit to 8-bit per dimension) | Configurable by target dimension; 2-10x common |
Distance Computation Method | Asymmetric Distance Computation (ADC) via precomputed lookup tables | Standard distance metrics on quantized integer representations | Euclidean distance in projected space with approximate distance preservation |
Preserves Original Space Geometry | |||
Requires Training/Clustering Phase | |||
Recall@10 on SIFT1M (64 bytes/vector) | ~95% with IVFADC index | ~98% with 8-bit quantization | ~85% at equivalent compression ratio |
Query-Time Overhead | Table lookup + partial distance aggregation; < 1 ms per query typical | Negligible; direct integer arithmetic | Single matrix multiplication; < 0.5 ms typical |
Susceptibility to Curse of Dimensionality | Mitigated by sub-vector partitioning; effective up to ~1000 dimensions | Unaffected; operates per-dimension independently | Strong theoretical guarantees; distortion bounded by O(log n / k) for target dimension k |
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 foundational technique for memory-efficient vector search. These related concepts form the core toolkit for building high-performance, cost-effective approximate nearest neighbor systems.
Approximate Nearest Neighbor (ANN)
The algorithmic category that Product Quantization serves. ANN trades a small, controlled amount of recall accuracy for massive gains in query speed and memory efficiency. Exact search scales linearly with dimensionality and dataset size, becoming prohibitive beyond millions of vectors. ANN algorithms, including those leveraging PQ, achieve sub-linear or logarithmic time complexity.
- Core Trade-off: Speed and memory vs. perfect accuracy
- Common Use: The retrieval step in RAG pipelines
- Key Metric: Recall@k (e.g., 99% recall with 10x compression)
Vector Embedding
The dense, low-dimensional numerical representation that Product Quantization compresses. Embeddings are generated by encoder models (e.g., text embedding models, CLIP for images) and capture semantic relationships in a continuous vector space. Dimensionality typically ranges from 384 (MiniLM) to 4096 (larger models), directly impacting PQ's sub-vector partitioning strategy.
- Typical Dimensions: 768 (BERT-base), 1536 (Ada-002)
- Data Type: Usually float32, consuming 4 bytes per dimension
- PQ Impact: A 1536-dim float32 vector (6KB) can be compressed to ~256 bytes
Encrypted Vector Database
A specialized data management system that indexes and queries high-dimensional embeddings while maintaining cryptographic privacy. Product Quantization introduces unique challenges in encrypted contexts because PQ centroids and codebooks constitute learned representations of the data distribution, which may leak information under certain threat models.
- Challenge: PQ codebooks are derived from plaintext data
- Mitigation: Train codebooks on public or synthetic data before encryption
- Integration: Combine with Homomorphic Encryption for distance computation over PQ codes

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