liveBook · Manning

Product quantization

As explained in Retrieval Augmented Generation, The Foundational Ideas

Product quantization compresses vectors by splitting them into subvectors and replacing each subvector with the index of its nearest entry in a learned codebook.

Product quantization (PQ) compresses dense vectors by splitting each vector into subvectors and replacing each subvector with the index of its nearest entry in a learned codebook. This lossy representation reduces memory substantially while preserving most retrieval quality. section 6.4.2

PQ solves a production constraint rather than replacing an index. Search strategy and vector storage are separate decisions: IVF or HNSW narrows the candidates, while PQ shrinks the stored vectors. IVF-PQ combines clustering with compression so large indexes fit in memory. section 2.2.2

Use PQ when the deployment trade-off favors a smaller index:

  • Expect roughly 8–16× lower memory use in large-scale FAISS indexes, with search quality retained well enough for billion-scale deployments. section 2.2.2
  • Accept lossy compression: PQ introduces a small retrieval-quality drop in exchange for a substantially smaller footprint. section 6.4.2
  • Treat compression as part of deployment planning when a Wikipedia-scale embedding index would otherwise exceed single-GPU capacity. section 6.4.2 section 6.5

Compressed retrieval for a large RAG index

A Wikipedia-scale RAG system can apply PQ to reduce its embedding index by roughly 10×, allowing the retriever and reader to coexist on one high-end GPU with only a small downstream-performance loss. Pairing PQ with IVF avoids scanning every compressed vector. section 6.4.2 section 6.5 section 2.2.2

Table 2.2 FAISS Indexing Strategies
Index Type
Best For
Key Trade-off
Seminal Paper / Origin
Flat Index (Exact Search)
The highest accuracy is required on smaller datasets (< 100K vectors). Critical for medical/legal diagnosis.
Slow, linear scaling time, making it unusable for big data.
Classical Baseline (Brute-force linear scan)
IVF (Inverted File)
Balance of speed and accuracy for mid-sized datasets (100K–10M vectors). Enterprise document search.
Parameter Sensitivity. Accuracy depends heavily on the number of clusters (nlist) and probes (nprobe).
"Video Google" (Sivic & Zisserman, 2003) adapted inverted indices for visual vectors.
HNSW (Hierarchical Navigable Small World)
Ultra-fast search is the top priority, especially for large datasets (> 1M vectors). Real-time recommendations.
High Memory Cost. ~90-95% accuracy with log-linear search time, but storing the graph structure consumes significant RAM.
Malkov and Yashunin (2016) introduced the hierarchical graph structure
Product Quantization (PQ)
Low Memory (mobile/embedded). Often combined with IVF (IVF-PQ) for billion-scale.
Lossy. Up to 10x memory reduction in exchange for a small drop in accuracy.
Jégou et al. (2011) defined subspace quantization for nearest neighbor search.

Compare flat, IVF, and HNSW search strategies alongside the separate choice to store vectors fully or in compressed form. section 2.2.2

How Retrieval Augmented Generation, The Foundational Ideas covers it

How deep it goes
Explains subvector codebooks, memory-quality trade-offs, and index composition, but stops short of implementation details for training PQ codebooks.
Examples
Uses FAISS-scale indexing, Wikipedia-scale RAG retrieval, and compressed indexes deployed beside a reader on one GPU.
What it assumes
Assumes familiarity with embeddings and similarity search while explaining why index narrowing and vector compression are independent choices.
What you can do after
Evaluate and configure compressed retrieval architectures by balancing index footprint, search strategy, latency, and retrieval quality.
How it connects
Connects product quantization to dense retrieval, inverted file indexes, HNSW, FAISS, and retrieval-augmented generation.

Also explained in

Compare how 4 books explain product quantization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Retrieval Augmented Generation, The Foundational Ideas. The section links point to the parts of the book it draws on.