pub trait Quantizer: Send + Sync {
type Quantized: Clone + Send + Sync;
// Required methods
fn quantize(&self, vector: &[f32]) -> Self::Quantized;
fn dequantize(&self, quantized: &Self::Quantized) -> Vec<f32>;
fn distance_quantized(
&self,
a: &Self::Quantized,
b: &Self::Quantized,
) -> f32;
fn distance_asymmetric(
&self,
query: &[f32],
quantized: &Self::Quantized,
) -> f32;
}Expand description
Trait for vector quantization
Required Associated Types§
Required Methods§
Sourcefn dequantize(&self, quantized: &Self::Quantized) -> Vec<f32>
fn dequantize(&self, quantized: &Self::Quantized) -> Vec<f32>
Dequantize back to f32 (lossy)
Sourcefn distance_quantized(&self, a: &Self::Quantized, b: &Self::Quantized) -> f32
fn distance_quantized(&self, a: &Self::Quantized, b: &Self::Quantized) -> f32
Compute distance between quantized vectors (fast path)
Sourcefn distance_asymmetric(&self, query: &[f32], quantized: &Self::Quantized) -> f32
fn distance_asymmetric(&self, query: &[f32], quantized: &Self::Quantized) -> f32
Compute distance between f32 query and quantized vector (asymmetric)