pub struct Int8Vector { /* private fields */ }Expand description
int8 quantized vector with scale factor
Implementations§
Source§impl Int8Vector
impl Int8Vector
Sourcepub fn from_f32(values: &[f32]) -> Self
pub fn from_f32(values: &[f32]) -> Self
Create int8 vector from fp32 using symmetric quantization
Best for normalized embeddings centered around 0.
Sourcepub fn from_f32_with_scale(values: &[f32], scale: f32) -> Self
pub fn from_f32_with_scale(values: &[f32], scale: f32) -> Self
Create int8 vector with pre-computed scale
Sourcepub fn size_bytes(&self) -> usize
pub fn size_bytes(&self) -> usize
Get size in bytes
Sourcepub fn dot_product(&self, other: &Self) -> f32
pub fn dot_product(&self, other: &Self) -> f32
Compute dot product with another int8 vector
Returns scaled dot product in fp32.
Sourcepub fn dot_product_f32(&self, query: &[f32]) -> f32
pub fn dot_product_f32(&self, query: &[f32]) -> f32
Compute dot product with fp32 query (asymmetric)
Query stays in fp32 for better precision. This is the recommended approach for rescoring.
Sourcepub fn l2_squared(&self, other: &Self) -> f32
pub fn l2_squared(&self, other: &Self) -> f32
Compute L2 squared distance to another int8 vector
Sourcepub fn cosine_distance(&self, other: &Self) -> f32
pub fn cosine_distance(&self, other: &Self) -> f32
Compute cosine distance using normalized dot product
Assumes vectors were normalized before quantization.
Trait Implementations§
Source§impl Clone for Int8Vector
impl Clone for Int8Vector
Source§fn clone(&self) -> Int8Vector
fn clone(&self) -> Int8Vector
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Int8Vector
impl RefUnwindSafe for Int8Vector
impl Send for Int8Vector
impl Sync for Int8Vector
impl Unpin for Int8Vector
impl UnsafeUnpin for Int8Vector
impl UnwindSafe for Int8Vector
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> 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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request