pub struct Int8Quantizer { /* private fields */ }Expand description
Per-dimension affine Int8 quantizer.
Maps each dimension independently: u8_val = round((f32_val - offset) / scale * 255)
where offset = min and scale = max - min per dimension.
Trained from sample vectors to learn the per-dimension ranges.
Implementations§
Source§impl Int8Quantizer
impl Int8Quantizer
Sourcepub fn train(vectors: &[Vec<f32>]) -> Result<Self, DiskAnnError>
pub fn train(vectors: &[Vec<f32>]) -> Result<Self, DiskAnnError>
Train an Int8 quantizer from sample vectors.
Computes per-dimension min/max to establish the affine mapping.
Sourcepub fn from_params(dim: usize, scales: Vec<f32>, offsets: Vec<f32>) -> Self
pub fn from_params(dim: usize, scales: Vec<f32>, offsets: Vec<f32>) -> Self
Create from pre-computed scales and offsets.
Sourcepub fn load(path: &str) -> Result<Self, DiskAnnError>
pub fn load(path: &str) -> Result<Self, DiskAnnError>
Load from file.
Trait Implementations§
Source§impl Clone for Int8Quantizer
impl Clone for Int8Quantizer
Source§fn clone(&self) -> Int8Quantizer
fn clone(&self) -> Int8Quantizer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Int8Quantizer
impl Debug for Int8Quantizer
Source§impl<'de> Deserialize<'de> for Int8Quantizer
impl<'de> Deserialize<'de> for Int8Quantizer
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Int8Quantizer
impl Serialize for Int8Quantizer
Source§impl VectorQuantizer for Int8Quantizer
impl VectorQuantizer for Int8Quantizer
Source§fn decode(&self, codes: &[u8]) -> Vec<f32>
fn decode(&self, codes: &[u8]) -> Vec<f32>
Decode compressed bytes back to an approximate float vector.
Source§fn asymmetric_distance(&self, query: &[f32], codes: &[u8]) -> f32
fn asymmetric_distance(&self, query: &[f32], codes: &[u8]) -> f32
Compute asymmetric distance: exact query vs quantized database vector.
Source§fn compression_ratio(&self, dim: usize) -> f32
fn compression_ratio(&self, dim: usize) -> f32
Compression ratio for a given dimension (original bytes / compressed bytes).
Auto Trait Implementations§
impl Freeze for Int8Quantizer
impl RefUnwindSafe for Int8Quantizer
impl Send for Int8Quantizer
impl Sync for Int8Quantizer
impl Unpin for Int8Quantizer
impl UnwindSafe for Int8Quantizer
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more