pub struct AdaptiveQuantizer { /* private fields */ }Expand description
Adaptive quantizer that adjusts step size based on local signal statistics
Uses a sliding window to compute local variance and adapts quantization step size accordingly. High-variance regions get finer quantization.
Implementations§
Source§impl AdaptiveQuantizer
impl AdaptiveQuantizer
Sourcepub fn new(
bits: u8,
window_size: usize,
adaptation_strength: f32,
global_min: f32,
global_max: f32,
) -> TokenizerResult<Self>
pub fn new( bits: u8, window_size: usize, adaptation_strength: f32, global_min: f32, global_max: f32, ) -> TokenizerResult<Self>
Create a new adaptive quantizer
Sourcepub fn quantize_adaptive(
&self,
signal: &Array1<f32>,
) -> TokenizerResult<Array1<i32>>
pub fn quantize_adaptive( &self, signal: &Array1<f32>, ) -> TokenizerResult<Array1<i32>>
Quantize entire signal with adaptation
Trait Implementations§
Source§impl Clone for AdaptiveQuantizer
impl Clone for AdaptiveQuantizer
Source§fn clone(&self) -> AdaptiveQuantizer
fn clone(&self) -> AdaptiveQuantizer
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 AdaptiveQuantizer
impl Debug for AdaptiveQuantizer
Source§impl Quantizer for AdaptiveQuantizer
impl Quantizer for AdaptiveQuantizer
Source§impl SignalTokenizer for AdaptiveQuantizer
impl SignalTokenizer for AdaptiveQuantizer
Source§fn encode(&self, signal: &Array1<f32>) -> TokenizerResult<Array1<f32>>
fn encode(&self, signal: &Array1<f32>) -> TokenizerResult<Array1<f32>>
Encode a continuous signal into tokens/embeddings
Source§fn decode(&self, tokens: &Array1<f32>) -> TokenizerResult<Array1<f32>>
fn decode(&self, tokens: &Array1<f32>) -> TokenizerResult<Array1<f32>>
Decode tokens/embeddings back to continuous signal
Source§fn vocab_size(&self) -> usize
fn vocab_size(&self) -> usize
Get the vocabulary size (for discrete tokenizers, 0 for continuous)
Auto Trait Implementations§
impl Freeze for AdaptiveQuantizer
impl RefUnwindSafe for AdaptiveQuantizer
impl Send for AdaptiveQuantizer
impl Sync for AdaptiveQuantizer
impl Unpin for AdaptiveQuantizer
impl UnwindSafe for AdaptiveQuantizer
Blanket Implementations§
Source§impl<T> BatchTokenizer for Twhere
T: SignalTokenizer,
impl<T> BatchTokenizer for Twhere
T: SignalTokenizer,
Source§fn encode_batch(&self, signals: &Array2<f32>) -> TokenizerResult<Array2<f32>>
fn encode_batch(&self, signals: &Array2<f32>) -> TokenizerResult<Array2<f32>>
Encode multiple signals in batch Read more
Source§fn decode_batch(&self, tokens: &Array2<f32>) -> TokenizerResult<Array2<f32>>
fn decode_batch(&self, tokens: &Array2<f32>) -> TokenizerResult<Array2<f32>>
Decode multiple token sequences in batch Read more
Source§fn encode_batch_padded_to(
&self,
signals: &[Array1<f32>],
target_len: usize,
) -> TokenizerResult<Array2<f32>>
fn encode_batch_padded_to( &self, signals: &[Array1<f32>], target_len: usize, ) -> TokenizerResult<Array2<f32>>
Encode batch with padding to handle variable length signals Read more
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 more