pub struct Reranker<'a> { /* private fields */ }Expand description
Reranker for computing int8 dot products with outlier correction
Implementations§
Source§impl<'a> Reranker<'a>
impl<'a> Reranker<'a>
Sourcepub fn new(
i8_data: &'a [i8],
scales: &'a [f32],
outliers: &'a [OutlierEntry],
dim: usize,
num_outliers: usize,
) -> Self
pub fn new( i8_data: &'a [i8], scales: &'a [f32], outliers: &'a [OutlierEntry], dim: usize, num_outliers: usize, ) -> Self
Create a new reranker
Sourcepub fn score(&self, vid: VectorId, query_i8: &[i8], query_scale: f32) -> f32
pub fn score(&self, vid: VectorId, query_i8: &[i8], query_scale: f32) -> f32
Compute dot product score for a single candidate
Uses SIMD-accelerated C++ kernels via FFI when available:
- AVX2: 32 int8 ops per cycle (8x speedup for dim=768)
- AVX512: 64 int8 ops per cycle (16x speedup)
- NEON: 16 int8 ops per cycle (4x speedup)
Sourcepub fn score_with_fp32(
&self,
vid: VectorId,
query_i8: &[i8],
query_scale: f32,
query_fp32: Option<&[f32]>,
) -> f32
pub fn score_with_fp32( &self, vid: VectorId, query_i8: &[i8], query_scale: f32, query_fp32: Option<&[f32]>, ) -> f32
Compute dot product score with optional fp32 query for accurate outlier computation.
When query_fp32 is provided, outlier contributions use exact fp32 values
instead of reconstructing from quantized int8, reducing error from O(1/127)
to floating-point epsilon.
§Arguments
vid- Vector ID to scorequery_i8- Quantized query vector (for main dot product)query_scale- Query quantization scalequery_fp32- Optional original fp32 query (for accurate outlier scoring)
Sourcepub fn score_batch(
&self,
candidates: &[VectorId],
query_i8: &[i8],
query_scale: f32,
) -> Vec<ScoredCandidate>
pub fn score_batch( &self, candidates: &[VectorId], query_i8: &[i8], query_scale: f32, ) -> Vec<ScoredCandidate>
Score multiple candidates in batch
Sourcepub fn score_batch_with_fp32(
&self,
candidates: &[VectorId],
query_i8: &[i8],
query_scale: f32,
query_fp32: &[f32],
) -> Vec<ScoredCandidate>
pub fn score_batch_with_fp32( &self, candidates: &[VectorId], query_i8: &[i8], query_scale: f32, query_fp32: &[f32], ) -> Vec<ScoredCandidate>
Score multiple candidates with fp32 query for accurate outlier computation
Sourcepub fn rerank(
&self,
candidates: &[VectorId],
query_i8: &[i8],
query_scale: f32,
r: usize,
) -> Vec<ScoredCandidate>
pub fn rerank( &self, candidates: &[VectorId], query_i8: &[i8], query_scale: f32, r: usize, ) -> Vec<ScoredCandidate>
Rerank and return top R candidates
Sourcepub fn rerank_with_fp32(
&self,
candidates: &[VectorId],
query_i8: &[i8],
query_scale: f32,
query_fp32: &[f32],
r: usize,
) -> Vec<ScoredCandidate>
pub fn rerank_with_fp32( &self, candidates: &[VectorId], query_i8: &[i8], query_scale: f32, query_fp32: &[f32], r: usize, ) -> Vec<ScoredCandidate>
Rerank with fp32 query for accurate outlier computation
Auto Trait Implementations§
impl<'a> Freeze for Reranker<'a>
impl<'a> RefUnwindSafe for Reranker<'a>
impl<'a> Send for Reranker<'a>
impl<'a> Sync for Reranker<'a>
impl<'a> Unpin for Reranker<'a>
impl<'a> UnsafeUnpin for Reranker<'a>
impl<'a> UnwindSafe for Reranker<'a>
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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