pub struct CodebookBuilder { /* private fields */ }Expand description
Multi-stage Vector Codebook Builder implementing Stage 2 of NOVAQ
Mathematical formulation: For each subspace k:
- Coarse quantization: b^(1){i,k} = argmin_c ||v{i,k} - C^(1)_{c,k}||²
- Residual calculation: r_{i,k} = v_{i,k} - C^(1){b^(1){i,k},k}
- Residual quantization: b^(2){i,k} = argmin_c ||r{i,k} - C^(2)_{c,k}||²
Final reconstruction: W_{i,:} = Σ_{k=1}^N (C^(1){b^(1){i,k},k} + C^(2){b^(2){i,k},k})
Implementations§
Source§impl CodebookBuilder
impl CodebookBuilder
pub fn new( num_subspaces: usize, codebook_size_l1: usize, codebook_size_l2: usize, seed: u64, ) -> Self
Sourcepub fn build_codebooks(
&mut self,
weights: &WeightMatrix,
) -> Result<(VectorCodebooks, QuantizationIndices)>
pub fn build_codebooks( &mut self, weights: &WeightMatrix, ) -> Result<(VectorCodebooks, QuantizationIndices)>
Build multi-stage vector codebooks for given weight matrix with enhanced stability
Sourcepub fn reconstruct_weights(
&self,
codebooks: &VectorCodebooks,
indices: &QuantizationIndices,
rows: usize,
cols: usize,
) -> Result<Vec<f32>>
pub fn reconstruct_weights( &self, codebooks: &VectorCodebooks, indices: &QuantizationIndices, rows: usize, cols: usize, ) -> Result<Vec<f32>>
Reconstruct weights from codebooks and indices
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CodebookBuilder
impl RefUnwindSafe for CodebookBuilder
impl Send for CodebookBuilder
impl Sync for CodebookBuilder
impl Unpin for CodebookBuilder
impl UnsafeUnpin for CodebookBuilder
impl UnwindSafe for CodebookBuilder
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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