Home Knowledge Base Product Quantization (PQ)

Product Quantization (PQ) is a vector compression technique that reduces high-dimensional embeddings to compact codes, enabling efficient storage and fast similarity search in RAG (Retrieval-Augmented Generation) systems. It achieves 10-100× compression with controlled accuracy loss.

How Product Quantization Works

1. Split: Divide each D-dimensional vector into M sub-vectors of dimension D/M. For example, split a 768-dim vector into 96 sub-vectors of 8 dimensions each. 2. Cluster: For each sub-vector position, run K-means clustering on training data to learn a codebook of K centroids (typically K=256, requiring 8 bits). 3. Encode: Replace each sub-vector with the index of its nearest centroid in the corresponding codebook. 4. Result: The original vector (768 floats = 3,072 bytes) becomes M bytes (96 bytes) — a 32× compression.

Distance Computation

To compute similarity between a query vector and PQ-encoded vectors:

Advantages

Trade-offs

Use in Vector Databases

PQ is a core component of FAISS (Facebook AI Similarity Search) and is used in production vector databases:

Typical Configuration

Product quantization is essential for large-scale RAG — it makes billion-vector search practical on commodity hardware.

product quantizationrag

Related Topics

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.