vindex

DuckDB Vector Search Extension

Classical product quantization: each vector split into m sub-vectors, each independently k-means quantized. Compact codes, ADC-based distance lookup.

GitHub
Quick Install
Version v0.1.0
← Back to overview
Quantizer

PQ

Classical product quantization: each vector split into m sub-vectors, each independently k-means quantized. Compact codes, ADC-based distance lookup.

Reference Paper — Credits

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

OptionDefaultNotes
mdim / 4Must divide dim. Common choices: 16 or 32 for d=128.
bits8bits ∈ {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);