What is a product-quantization index?

A product-quantization index is an ANN structure whose primary stored representation of each vector is a PQ code - subspace centroid IDs - so search ranks candidates by approximate distances computed from those codes (often after a coarse partition narrows which codes to score), rather than treating PQ as a mere add-on compressor on top of a separate graph.
Created: Updated: 4 min read

A product-quantization index is an ANN structure whose primary stored representation of each vector is a PQ code – subspace centroid IDs – so search ranks candidates by approximate distances computed from those codes (often after a coarse partition narrows which codes to score), rather than treating PQ as a mere add-on compressor on top of a separate graph.

How is a PQ index different from “HNSW with PQ compression”?

Product quantization as a technique splits vectors into segments and replaces each segment with a codebook index; that idea appears in many systems. A product-quantization index makes those codes the backbone of retrieval: the database you probe is a table of codes (and usually posting lists or another candidate generator), and the distance kernel is asymmetric or symmetric comparison against codebooks – ADC-style table lookups are common. By contrast, HNSW with PQ still navigates neighbor edges; PQ only shrinks what each node stores and how each hop is scored. Vector databases such as Weaviate commonly use that second pattern – graph first, quantization to cut RAM – while the classic “PQ index” lineage in the ANN taxonomy is compression-centric and often paired with inverted-file partitioning. Same codec family, different spine.

In practice the spine is usually “coarse cell, then PQ score,” not codes alone in a flat scan.

How does search typically run inside a product-quantization index?

Training fits PQ codebooks (and, for IVF+PQ, a coarse quantizer). Each vector is encoded into m small integers and filed into its cell’s list. A query is compared to coarse centroids to pick nprobe lists, then scored against list members using PQ distance estimates – often with the query kept in higher precision while database rows stay coded. Top-k comes from those estimates, sometimes followed by a full-precision rerank on a shortlist (two-stage retrieval). Tuning spans codebook size, segment count, nlist/nprobe, and whether residuals relative to the coarse centroid are what get PQ-encoded. Memory scales with codes plus codebooks plus list structure – frequently far below storing float32 payloads for every vector – at the cost of quantization error in every comparison.

That error profile shapes when a PQ index is the right tool versus a graph.

What strengths and limits should you expect from PQ-first indexes?

Strengths include aggressive memory reduction, predictable storage layouts friendly to batch scans, and a clear accounting of bytes per vector. Limits include training and reclustering cost, sensitivity to codebook freshness as data drifts, and recall that depends heavily on partition coverage plus code fidelity. Unlike HNSW’s efSearch beam on a navigable graph, missing the right IVF cell cannot be fixed by “walking a bit further” – you must raise nprobe or improve the coarse quantizer. Pure flat PQ without partitions turns into scoring huge fractions of the collection, which defeats the point unless the set is modest. Hybrid ANN indexes that bolt PQ codes onto graphs try to get both navigation and compression; a pure PQ index leans on partitions and scans instead.

Choosing among those designs is an operating-point decision, not a brand loyalty test.

When should you prefer a product-quantization index over HNSW or other families?

Prefer a PQ-centric index when RAM per vector dominates the budget, when batch-oriented list scans fit your hardware, and when you can schedule training plus occasional rebuilds. Prefer HNSW (optionally with its own PQ compression) when incremental inserts and high recall at low latency on dense embeddings are paramount. Prefer tree or LSH methods only when their geometric or probabilistic assumptions match lower-dimensional or threshold-shaped problems better. Always plot recall versus latency while sweeping nprobe and segment count, and validate after corpus shifts that force codebook retraining. A product-quantization index is ANN built around codes; treat the codebooks as part of the index, not as a detachable codec.

A product-quantization index stores and searches PQ codes as the main ANN representation – usually behind coarse partitions – rather than only using PQ to shrink an HNSW node payload. From here, product quantization explains the codec itself, inverted file indexes cover the usual partner structure, two-stage retrieval and full-precision reranking describe the accuracy safety net, and the taxonomy of ANN methods places PQ indexes among compression-based approaches beside graphs, trees, and hashes.