pub struct BbqCodec {
pub dim: usize,
pub oversample: u8,
/* private fields */
}Expand description
BBQ centroid-centered asymmetric 1-bit quantization codec.
Calibration computes the dataset centroid which is subtracted from each vector before sign quantization. The resulting 1-bit codes are Hamming- coarse-comparable; exact rerank uses the 14-byte corrective factors stored in the unified header.
Fields§
§dim: usize§oversample: u8Oversample multiplier for the caller’s rerank pass. Caller fetches
oversample × top_k coarse candidates from the Hamming coarse pass,
then calls exact_asymmetric_distance on each.
Implementations§
Trait Implementations§
Source§impl VectorCodec for BbqCodec
impl VectorCodec for BbqCodec
Source§fn fast_symmetric_distance(&self, q: &BbqQuantized, v: &BbqQuantized) -> f32
fn fast_symmetric_distance(&self, q: &BbqQuantized, v: &BbqQuantized) -> f32
Fast Hamming-based symmetric distance estimate.
Uses the asymmetric corrective distance formula:
approx = q_n² + v_n² − 2 · q_n · v_n · dot_estimate
where dot_estimate = 1 − 2·hamming/dim maps the Hamming count to
a normalised cosine-like similarity on {−1,+1} codes.
Source§fn exact_asymmetric_distance(&self, q: &BbqQuery, v: &BbqQuantized) -> f32
fn exact_asymmetric_distance(&self, q: &BbqQuery, v: &BbqQuantized) -> f32
Exact asymmetric L2 distance using the dequantized stored vector.
The query is exact centered FP32 (q.centered). The stored vector is
reconstructed from its sign bits and residual_norm via
BbqCodec::dequantize: each dimension ≈ ±residual_norm / √dim.
This is the high-fidelity asymmetric path invoked during rerank on the
oversample × top_k candidates returned by the coarse Hamming pass.
Source§type Quantized = BbqQuantized
type Quantized = BbqQuantized
UnifiedQuantizedVector
reference via AsRef.Source§fn encode(&self, v: &[f32]) -> BbqQuantized
fn encode(&self, v: &[f32]) -> BbqQuantized
Source§fn prepare_query(&self, q: &[f32]) -> BbqQuery
fn prepare_query(&self, q: &[f32]) -> BbqQuery
Auto Trait Implementations§
impl Freeze for BbqCodec
impl RefUnwindSafe for BbqCodec
impl Send for BbqCodec
impl Sync for BbqCodec
impl Unpin for BbqCodec
impl UnsafeUnpin for BbqCodec
impl UnwindSafe for BbqCodec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.