pub struct LinearQuantizer { /* private fields */ }Expand description
Linear uniform quantizer
Implementations§
Source§impl LinearQuantizer
impl LinearQuantizer
Sourcepub fn new(min: f32, max: f32, bits: u8) -> TokenizerResult<Self>
pub fn new(min: f32, max: f32, bits: u8) -> TokenizerResult<Self>
Create a new linear quantizer
Sourcepub fn normalized(bits: u8) -> TokenizerResult<Self>
pub fn normalized(bits: u8) -> TokenizerResult<Self>
Create quantizer for normalized [-1, 1] range
Trait Implementations§
Source§impl Clone for LinearQuantizer
impl Clone for LinearQuantizer
Source§fn clone(&self) -> LinearQuantizer
fn clone(&self) -> LinearQuantizer
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 LinearQuantizer
impl Debug for LinearQuantizer
Source§impl Quantizer for LinearQuantizer
impl Quantizer for LinearQuantizer
Source§impl SignalTokenizer for LinearQuantizer
impl SignalTokenizer for LinearQuantizer
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)
Source§impl TokenizerIO for LinearQuantizer
impl TokenizerIO for LinearQuantizer
Source§fn save_binary<P: AsRef<Path>>(&self, path: P) -> TokenizerResult<()>
fn save_binary<P: AsRef<Path>>(&self, path: P) -> TokenizerResult<()>
Save to binary file (using bincode)
Source§fn load_binary<P: AsRef<Path>>(path: P) -> TokenizerResult<Self>
fn load_binary<P: AsRef<Path>>(path: P) -> TokenizerResult<Self>
Load from binary file (using bincode)
Auto Trait Implementations§
impl Freeze for LinearQuantizer
impl RefUnwindSafe for LinearQuantizer
impl Send for LinearQuantizer
impl Sync for LinearQuantizer
impl Unpin for LinearQuantizer
impl UnwindSafe for LinearQuantizer
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