pub struct SpeculativeDecoderConfig {
pub k: usize,
pub cost_ratio: f32,
pub stop_on_eos: bool,
pub eos_token: Option<TokenId>,
}Expand description
Configuration for the speculative decoder.
Fields§
§k: usizeNumber of draft tokens to propose per round (default 4).
cost_ratio: f32Cost ratio c_draft / c_target for speedup modeling (default 0.125).
stop_on_eos: boolIf true, the engine halts the generation loop on the first
eos_token it emits.
eos_token: Option<TokenId>Optional end-of-sequence token id (ignored unless stop_on_eos).
Implementations§
Source§impl SpeculativeDecoderConfig
impl SpeculativeDecoderConfig
Sourcepub fn with_cost_ratio(self, r: f32) -> Self
pub fn with_cost_ratio(self, r: f32) -> Self
Convenience builder: set cost ratio for the speedup estimate.
Sourcepub fn with_eos(self, eos: TokenId) -> Self
pub fn with_eos(self, eos: TokenId) -> Self
Convenience builder: attach an EOS token and enable early stopping.
Sourcepub fn validate(&self) -> SpeculativeDecodingResult<()>
pub fn validate(&self) -> SpeculativeDecodingResult<()>
Validate the configuration, returning an SpeculativeDecodingError
if any invariant is violated.
Trait Implementations§
Source§impl Clone for SpeculativeDecoderConfig
impl Clone for SpeculativeDecoderConfig
Source§fn clone(&self) -> SpeculativeDecoderConfig
fn clone(&self) -> SpeculativeDecoderConfig
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 SpeculativeDecoderConfig
impl Debug for SpeculativeDecoderConfig
Source§impl Default for SpeculativeDecoderConfig
impl Default for SpeculativeDecoderConfig
Source§impl PartialEq for SpeculativeDecoderConfig
impl PartialEq for SpeculativeDecoderConfig
impl StructuralPartialEq for SpeculativeDecoderConfig
Auto Trait Implementations§
impl Freeze for SpeculativeDecoderConfig
impl RefUnwindSafe for SpeculativeDecoderConfig
impl Send for SpeculativeDecoderConfig
impl Sync for SpeculativeDecoderConfig
impl Unpin for SpeculativeDecoderConfig
impl UnsafeUnpin for SpeculativeDecoderConfig
impl UnwindSafe for SpeculativeDecoderConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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