pub struct ScalarQuantizer {
pub dmin: Vec<f32>,
pub dscale: Vec<f32>,
}Expand description
Per-dimension linear int8 quantizer. Codes are i8 in [-128, 127].
Fields§
§dmin: Vec<f32>Per-dimension minimum value seen during fit.
dscale: Vec<f32>Per-dimension step size: (max - min) / 255. Zero-range dims use 1.0.
Implementations§
Source§impl ScalarQuantizer
impl ScalarQuantizer
Sourcepub fn fit(dimension: usize, sample: &[Vector]) -> Self
pub fn fit(dimension: usize, sample: &[Vector]) -> Self
Learn per-dimension min/scale from a sample of vectors.
pub fn dimension(&self) -> usize
Sourcepub fn reconstruct_at(&self, code: i8, i: usize) -> f32
pub fn reconstruct_at(&self, code: i8, i: usize) -> f32
Reconstruct dimension i of a code back to full precision.
Sourcepub fn dequantize(&self, codes: &[i8]) -> Vec<f32>
pub fn dequantize(&self, codes: &[i8]) -> Vec<f32>
Reconstruct a full code slice into a float vector.
Trait Implementations§
Source§impl Clone for ScalarQuantizer
impl Clone for ScalarQuantizer
Source§impl Debug for ScalarQuantizer
impl Debug for ScalarQuantizer
Source§impl Default for ScalarQuantizer
impl Default for ScalarQuantizer
Source§impl<'de> Deserialize<'de> for ScalarQuantizer
impl<'de> Deserialize<'de> for ScalarQuantizer
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
Auto Trait Implementations§
impl Freeze for ScalarQuantizer
impl RefUnwindSafe for ScalarQuantizer
impl Send for ScalarQuantizer
impl Sync for ScalarQuantizer
impl Unpin for ScalarQuantizer
impl UnsafeUnpin for ScalarQuantizer
impl UnwindSafe for ScalarQuantizer
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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