Skip to main content

Module bbq

Module bbq 

Source
Expand description

RerankCodec wrapper for BBQ (Better Binary Quantization).

BBQ is a training-based codec: train() calibrates a centroid from a sample of vectors. Until training is complete, encode and prepare_query return RerankError::NotTrained.

Distance uses the asymmetric path from the BBQ paper: the query is kept in centered FP32; the stored vector is reconstructed from its 1-bit sign pack and residual_norm (≈ ±norm/√dim per dimension). The L2 distance between the exact centered query and the reconstructed candidate is returned.

The prepared form is PreparedQuery::Bytes with the layout: [0..4] alpha (query_norm) as f32 little-endian [4..4+dim*4] centered f32 values, each as f32 little-endian

Structs§

BbqRerank
Object-safe RerankCodec wrapper around BbqCodec.

Constants§

DEFAULT_OVERSAMPLE
Default oversample multiplier used when the caller does not specify one.