PQ
Classical product quantization: each vector split into m sub-vectors, each independently k-means quantized. Compact codes, ADC-based distance lookup.
Product Quantization for Nearest Neighbor Search
Jégou, H.; Douze, M.; Schmid, C.
IEEE TPAMI 2011
Decomposes each vector into subvectors independently quantized via k-means codebooks — the foundation of compressed ANN search.
Read paper at official venue →At a glance
Product Quantization decomposes each d-dimensional vector into m equally-sized sub-vectors and
trains an independent k-means codebook per sub-vector (2^bits centroids each). The stored code
is the concatenation of sub-vector codebook IDs — m × (bits/8)
bytes total. At query time, distances are estimated via ADC: precompute the query-to-centroid
table once, then each candidate is one gather-add per sub-vector.
Parameters
| Option | Default | Notes |
|---|---|---|
| m | dim / 4 | Must divide dim. Common choices: 16 or 32 for d=128. |
| bits | 8 | bits ∈ {4, 8}. 4-bit halves memory with modest recall loss. |
Example
CREATE INDEX docs_idx ON docs USING HNSW (embedding)
WITH (metric='l2sq', quantizer='pq', m=16, bits=8, rerank=10);