Product Quantization: Vector Compression for ANN Search › Summary
Michael BrenndoerferJanuary 28, 20262 min read
Language AI HandbookAll chapters Part 44 of 67Retrieval-Augmented Generation
Product Quantization: Vector Compression for ANN Search › SummaryOne section · Sections in this chapter11 / 12 ↓
Sections in this chapter12
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Product Quantization compresses high-dimensional vectors into compact codes by splitting each vector into subvectors and replacing each with the index of its nearest centroid in a learned codebook:
- Codebook learning runs k-means independently in each of the subspaces on a sample of your training data. Each subspace gets centroids (typically for one-byte codes). The codebooks must match your data distribution; mismatched codebooks inflate quantization error and reduce recall.
- Encoding replaces each subvector with its centroid index, compressing a float32 vector of dimensions (which requires bytes) to bytes (one byte per subspace when nbits=8), giving a compression ratio of . Encoding happens once at index build time and the result is stored as compact integer codes.
- Asymmetric Distance Computation precomputes a lookup table of distances from the query to all centroids in each subspace, then reduces each database comparison to table lookups and additions. The lookup tables fit in CPU cache, making ADC limited by memory bandwidth rather than arithmetic throughput.
- The recall-compression trade-off is governed by the total code length . At fixed
nbits, more subspaces mean more bytes, less compression, lower reconstruction error, and generally higher recall. For 768-dimensional embeddings withnbits=8, and correspond to 48-byte and 96-byte codes respectively. - IVFPQ combines coarse partitioning (IVF) with compression (PQ), achieving both fewer comparisons and smaller memory footprint. This is the dominant configuration in production vector search systems, used by Pinecone, Weaviate, Milvus, and the FAISS library.
- At scale, PQ is what makes billion-vector indexes feasible on a single server, transforming a distributed-computing problem into one that runs on commodity hardware. The practical difference between a 3 TB flat index and a 48 GB PQ index is the difference between a cluster deployment and a single machine.