Product Quantization (PQ) is a lossy compression method for high-dimensional vectors that splits a vector into M distinct sub-vectors. Each sub-vector is independently quantized by mapping it to the nearest centroid in a pre-trained codebook of k codewords. The original vector is then stored as a compact code—a sequence of M integer indices—reducing memory from D * 32 bits to M * log2(k) bits, enabling billion-scale approximate nearest neighbor (ANN) search entirely in RAM.
Glossary
Product Quantization (PQ)

What is Product Quantization (PQ)?
Product Quantization (PQ) is a vector compression technique that decomposes high-dimensional vectors into smaller sub-vectors and quantizes each independently using a learned codebook, dramatically reducing the memory footprint of an index for large-scale similarity search.
During search, the query vector is similarly decomposed, and distances are computed efficiently using pre-calculated lookup tables between query sub-vectors and codebook centroids. This asymmetric distance computation (ADC) avoids reconstructing full vectors, trading a small accuracy loss for massive speed gains. PQ is often combined with an inverted file index (IVF-PQ) for coarse pre-filtering, forming the backbone of memory-efficient vector databases like Faiss.
Key Features of Product Quantization
Product Quantization (PQ) is a lossy compression technique that decomposes high-dimensional vectors into smaller sub-vectors and quantizes each independently using a learned codebook. This dramatically reduces the memory footprint of an index for large-scale similarity search.
Sub-Vector Decomposition
The core mechanism of PQ involves splitting a high-dimensional vector (e.g., 1024 dimensions) into M distinct, lower-dimensional sub-vectors (e.g., 8 sub-vectors of 128 dimensions each). This decomposition is the foundational step that makes independent quantization possible. The original vector is reconstructed by concatenating the quantized representations of its sub-vectors.
Independent Codebook Learning
For each of the M sub-spaces, a separate codebook is learned using k-means clustering on the training data. Each codebook contains k centroid vectors (e.g., 256 centroids). During quantization, each original sub-vector is replaced by the ID of its nearest centroid in that sub-space's codebook. This replaces floating-point vectors with compact integer codes.
Memory Footprint Reduction
PQ achieves massive compression by storing only the centroid IDs instead of the original floating-point vectors.
- Original vector: 1024 dimensions × 4 bytes (float32) = 4096 bytes
- PQ-compressed: 8 sub-vectors × 1 byte (for k=256) = 8 bytes This represents a 512x reduction in storage, enabling billion-scale vector indexes to fit entirely in RAM.
Asymmetric Distance Computation (ADC)
To perform similarity search without decompressing the entire database, PQ uses Asymmetric Distance Computation. The query vector is kept in full precision and split into sub-vectors. The distances between each query sub-vector and all centroids in the corresponding codebook are pre-computed into a lookup table. The distance to any compressed database vector is then approximated by summing the pre-computed distances from the lookup table using the stored centroid IDs.
Trade-off: Compression vs. Recall
PQ is a lossy compression method. The approximation error is controlled by two hyperparameters:
- M (number of sub-vectors): Fewer sub-vectors means coarser quantization and higher compression but lower accuracy.
- k (number of centroids per codebook): More centroids provide finer granularity but require more bits per code (e.g., k=256 requires 8 bits). Tuning these parameters balances the memory-accuracy trade-off for a specific application.
Integration with Inverted File Index (IVF)
PQ is often combined with an Inverted File (IVF) structure to avoid exhaustive search. The vector space is first partitioned into Voronoi cells using coarse quantization. A query only visits the nearest cells. Within each cell, vectors are stored in PQ-compressed form. This two-stage approach—coarse partitioning followed by fine PQ compression—is the foundation of the IVFPQ index, a standard for billion-scale ANN search.
Frequently Asked Questions
Clear, technical answers to the most common questions about Product Quantization (PQ), its mechanisms, and its role in scaling high-dimensional vector search.
Product Quantization (PQ) is a vector compression technique that decomposes a high-dimensional vector into smaller, independent sub-vectors and quantizes each one using a distinct, pre-learned codebook. The process begins by splitting a D-dimensional vector into M sub-vectors of dimension D/M. A k-means clustering algorithm is run on each sub-space independently to generate a codebook of k centroids. The original vector is then represented not by its floating-point values, but by the M short codes (typically 8-bit integers) that identify the nearest centroid for each sub-vector. This replaces the full-precision vector with a compact code, dramatically reducing memory usage while enabling fast approximate distance calculations via table lookups.
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.
Product Quantization vs. Other Compression Techniques
A technical comparison of Product Quantization against alternative vector compression methods for approximate nearest neighbor search, evaluating memory footprint, recall, and computational trade-offs.
| Feature | Product Quantization (PQ) | Scalar Quantization (SQ) | Binary Embeddings |
|---|---|---|---|
Compression Mechanism | Sub-vector clustering with learned codebooks | Per-dimension float-to-int8 mapping | Per-dimension thresholding to single bit |
Memory Reduction Factor | 8-32x (e.g., 128-dim float32 to 32 bytes) | 4x (float32 to int8) | 32x (float32 to 1 bit) |
Distance Computation | Asymmetric Distance Computation (ADC) via lookup tables | Integer arithmetic or dequantized float math | Hamming distance via XOR and popcount |
Recall@10 vs. Exact Search | 90-98% with optimal parameters | 99%+ with minimal loss | 70-85% on complex semantic tasks |
Codebook Training Required | |||
Supports Inner Product Search | |||
Sub-vector Independence Assumption | |||
Typical Use Case | Billion-scale ANN indexes with tight memory budgets | Moderate compression with near-lossless recall | Edge devices and ultra-fast filtering stages |
Related Terms
Product Quantization is a core compression technique within a larger ecosystem of algorithms designed to make billion-scale vector search economically viable. These related terms define the infrastructure, alternatives, and scoring mechanisms that interact with PQ-based indexes.
Approximate Nearest Neighbor (ANN)
The class of algorithms that trade a small amount of accuracy for significant speed improvements when finding the closest vectors to a query in high-dimensional embedding spaces. PQ is a compression technique that enables ANN indexes to store vectors in memory, but the ANN algorithm itself—such as HNSW or IVF—is responsible for the actual search traversal. Without ANN, exhaustive search over PQ-compressed vectors would still be computationally prohibitive at scale.
Inverted File Index (IVF)
A partitioning strategy that clusters the vector space into Voronoi cells using k-means, assigning each vector to its nearest centroid. At query time, only a small number of cells are searched. IVF is the most common pairing with Product Quantization, forming the IVFPQ index. The IVF coarse quantizer narrows the search scope, while PQ compresses the residual vectors within each cell, combining to deliver sub-linear search complexity with a drastically reduced memory footprint.
Scalar Quantization (SQ)
A simpler compression alternative that maps each continuous floating-point dimension to a discrete integer representation, typically converting 32-bit floats to 8-bit integers. Unlike PQ, SQ does not decompose the vector into sub-vectors, making it less aggressive in compression but faster to encode and decode. SQ is often used as a baseline: it achieves a 4x memory reduction with minimal accuracy loss, while PQ can achieve 8-16x or more by exploiting subspace structure.
Asymmetric Distance Computation (ADC)
The standard query-time distance estimation method for PQ. In ADC, the query vector is not quantized; instead, the distances between the query's sub-vectors and all centroids in each codebook are pre-computed into lookup tables. The distance to a database vector is then approximated by summing the corresponding pre-computed distances. This asymmetry preserves more information from the query, yielding higher search accuracy than the symmetric variant where both query and database vectors are quantized.
Optimized Product Quantization (OPQ)
An enhancement to standard PQ that learns an orthogonal rotation matrix applied to the vector space before subspace decomposition. This rotation decorrelates dimensions and balances the variance across sub-vectors, ensuring that each codebook captures roughly equal information. OPQ significantly reduces quantization error compared to naive PQ, especially for data with correlated dimensions, and is a default preprocessing step in FAISS for maximum recall at a given compression rate.
Residual Quantization
A multi-stage compression approach where the error between the original vector and its first-level quantization is quantized by a second codebook, and so on. Unlike PQ, which partitions the vector space into orthogonal subspaces, residual quantization applies successive corrections to the full vector. This hierarchical refinement can achieve lower distortion than PQ for a given bitrate, but lacks the fast distance computation structure that makes PQ so efficient for ANN search.

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