Skip to main content

Module pq

Module pq 

Source
Expand description

RerankCodec wrapper for Product Quantization (PQ).

PQ is a training-based codec: train() runs k-means over a sample of vectors to learn per-subspace codebooks. Until training is complete, encode and prepare_query return RerankError::NotTrained.

Distance uses the ADC (Asymmetric Distance Computation) model: the query is kept in FP32 and a per-subspace lookup table is precomputed once via prepare_query; each candidate lookup is then O(M) table additions. The prepared form maps directly to PreparedQuery::Lut — the existing variant already holds Vec<Vec<f32>> which is exactly the PQ distance table (lut[sub][centroid]).

Structs§

PqRerank
Object-safe RerankCodec wrapper around PqCodec.