Product Quantization: Vector Compression for ANN Search › Product Quantization

Michael BrenndoerferJanuary 28, 20264 min read
Language AI HandbookAll chapters
Part 44 of 67Retrieval-Augmented Generation
Chapter 341Product Quantization: Vector Compression for ANN Search › Product Quantization
Reading section 1 of 12 · Product Quantization · 4 minSection 1 of 12 · 4 min

Book contents

Section 1 of 12 · 4 min read

Product Quantization: Vector Compression for ANN Search › Product QuantizationOne section · Sections in this chapter1 / 12 ↓
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

In the previous two chapters, we explored IVF indexes and HNSW graphs, two strategies that reduce the number of comparisons needed to find approximate nearest neighbors. But there is another bottleneck we have not addressed: even when you only compare a query against a small fraction of your index, each comparison still requires loading a full 768-dimensional float32 vector from memory and computing a dot product. When your index holds tens of millions of embeddings, that memory footprint alone can exceed the capacity of a single machine.

Product Quantization (PQ) attacks this problem from a different angle: rather than reducing the number of comparisons, PQ reduces the cost and size of each comparison. It compresses each embedding from hundreds of floating-point numbers down to a handful of small integers, achieving compression ratios of 10x to 100x while preserving enough geometric structure to compute useful approximate distances. The resulting index can fit in RAM where a full-precision index would require a distributed cluster.

Think of PQ as giving each vector a compact postal address rather than GPS coordinates. Instead of storing the precise latitude and longitude of every building in a city, you store only the zip code and block number. You lose some precision, but you gain the ability to store every address in the city in a pocket notebook. When someone asks "which buildings are near this location?", you can narrow the search to a few zip codes and find good candidates without ever loading the full coordinate database.

The insight that makes PQ so powerful is the combination of two ideas. First, the high-dimensional space can be factored into independent lower-dimensional subspaces, where each subspace is much easier to quantize accurately than the full space. Second, distances in the full space decompose exactly across those subspaces, so you can estimate the full distance by summing independently precomputed per-subspace distances. This second property is what allows the entire expensive computation to happen once per query rather than once per database vector, cutting the inner loop to a series of simple memory reads.

To understand why those two ideas combine to produce such dramatic speedups, you need to understand the geometry of quantization, why the product decomposition matters, and how the resulting lookup-table machinery achieves both memory compression and fast distance estimation. This chapter covers all three: how PQ codebooks are learned, how distances are approximated efficiently with Asymmetric Distance Computation, and how PQ combines with IVF to give you both reduced comparisons and reduced memory at scale.

The practical stakes are real. A production RAG system indexing 500 million document chunks at 768 dimensions needs roughly 1.5 TB of RAM just to hold the raw embeddings, which forces a distributed deployment. The same index with PQ at M=96M = 96 fits in 48 GB on a single server. This reduction can turn a distributed system that requires an infrastructure team into one that a single engineer can deploy and operate.

Historical Context

Product Quantization was introduced by Herve Jegou, Matthijs Douze, and Cordelia Schmid in their 2011 IEEE Transactions on Pattern Analysis and Machine Intelligence paper "Product Quantization for Nearest Neighbor Search." The key innovation was not quantization itself (vector quantization had been studied for decades in signal processing) but the product decomposition: by splitting vectors into independent subspaces and quantizing each independently, they transformed an intractable high-dimensional clustering problem into a collection of tractable low-dimensional ones. The paper also introduced Asymmetric Distance Computation (ADC), the lookup-table technique that makes PQ practical for large-scale retrieval. Their FAISS library, released by Meta AI Research in 2017, brought these ideas to production scale and is now the standard implementation used by essentially all major vector databases. The original PQ paper has accumulated thousands of citations and is widely regarded as one of the most practically impactful papers in large-scale information retrieval.