pub struct HybridDecoder { /* private fields */ }Expand description
Multi-hypothesis decoding strategy that tries multiple approaches
Implementations§
Source§impl HybridDecoder
impl HybridDecoder
Sourcepub fn new(config: DecodingConfig) -> Self
pub fn new(config: DecodingConfig) -> Self
Create a new hybrid decoder
Sourcepub fn decode(
&self,
token_probs: &[Vec<f32>],
initial_token: u32,
vocab_size: usize,
eos_token: u32,
pad_token: u32,
) -> Result<Vec<u32>>
pub fn decode( &self, token_probs: &[Vec<f32>], initial_token: u32, vocab_size: usize, eos_token: u32, pad_token: u32, ) -> Result<Vec<u32>>
Decode with beam-search / greedy fallback (no quality gating).
Sourcepub fn decode_with_fallback(
&self,
token_probs: &[Vec<f32>],
initial_token: u32,
vocab_size: usize,
eos_token: u32,
no_speech_token: u32,
decode_text: impl Fn(&[u32]) -> String,
) -> Result<Vec<u32>>
pub fn decode_with_fallback( &self, token_probs: &[Vec<f32>], initial_token: u32, vocab_size: usize, eos_token: u32, no_speech_token: u32, decode_text: impl Fn(&[u32]) -> String, ) -> Result<Vec<u32>>
Decode with quality-gated temperature fallback (faster-whisper SOTA strategy).
Iterates over config.temperatures in order. At each temperature, samples
tokens from the collected logits and checks:
no_speech_prob > no_speech_threshold→ return empty (silence)avg_log_prob < log_prob_threshold→ retry at next temperaturecompression_ratio > compression_ratio_threshold→ retry at next temperature
Returns the first result that passes all quality gates, or the last attempt if all temperatures are exhausted.
§Arguments
token_probs— per-step raw logits collected autoregressively from the decoderinitial_token— first token to prepend to the output sequencevocab_size— vocabulary size (bounds check forno_speech_token)eos_token— end-of-sequence token; stops generation when sampledno_speech_token— token whose first-step softmax probability signals silencedecode_text— closure that converts token IDs to a UTF-8 string for compression ratio
Auto Trait Implementations§
impl Freeze for HybridDecoder
impl RefUnwindSafe for HybridDecoder
impl Send for HybridDecoder
impl Sync for HybridDecoder
impl Unpin for HybridDecoder
impl UnsafeUnpin for HybridDecoder
impl UnwindSafe for HybridDecoder
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<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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