pub struct PyramidTokenizer { /* private fields */ }Expand description
Pyramid tokenizer with residual connections
Each level encodes the residual from the previous level’s reconstruction, similar to residual VQ (RVQ) used in audio codecs.
Implementations§
Source§impl PyramidTokenizer
impl PyramidTokenizer
Sourcepub fn new(
input_dim: usize,
embed_dim_per_level: usize,
num_levels: usize,
) -> Self
pub fn new( input_dim: usize, embed_dim_per_level: usize, num_levels: usize, ) -> Self
Create a new pyramid tokenizer
Sourcepub fn without_residual(self) -> Self
pub fn without_residual(self) -> Self
Disable residual encoding (use independent levels)
Sourcepub fn encode_pyramid(
&self,
signal: &Array1<f32>,
) -> TokenizerResult<Vec<Array1<f32>>>
pub fn encode_pyramid( &self, signal: &Array1<f32>, ) -> TokenizerResult<Vec<Array1<f32>>>
Encode with residual pyramid
Sourcepub fn decode_pyramid(
&self,
embeddings: &[Array1<f32>],
) -> TokenizerResult<Array1<f32>>
pub fn decode_pyramid( &self, embeddings: &[Array1<f32>], ) -> TokenizerResult<Array1<f32>>
Decode from pyramid embeddings
Sourcepub fn num_levels(&self) -> usize
pub fn num_levels(&self) -> usize
Get number of levels
Trait Implementations§
Source§impl Clone for PyramidTokenizer
impl Clone for PyramidTokenizer
Source§fn clone(&self) -> PyramidTokenizer
fn clone(&self) -> PyramidTokenizer
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 PyramidTokenizer
impl Debug for PyramidTokenizer
Source§impl SignalTokenizer for PyramidTokenizer
impl SignalTokenizer for PyramidTokenizer
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 PyramidTokenizer
impl RefUnwindSafe for PyramidTokenizer
impl Send for PyramidTokenizer
impl Sync for PyramidTokenizer
impl Unpin for PyramidTokenizer
impl UnwindSafe for PyramidTokenizer
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