pub trait SpeculativeSampler<B: SamplingBackend> {
// Required method
fn process_logits(
&mut self,
logits: &B::Logits,
temperature: f32,
history: &[u32],
context: &B::Context,
) -> Result<B::Logits, B::Error>;
// Provided methods
fn uses_checkpoint_defaults(&self) -> bool { ... }
fn supports_exact_optimistic_promotion(&self) -> bool { ... }
fn grammar_is_complete(&mut self) -> Result<bool, B::Error> { ... }
fn prefix_is_complete(&self, _history: &[u32]) -> Result<bool, B::Error> { ... }
fn sample_processed(
&self,
logits: &B::Logits,
temperature: f32,
random: Option<&mut B::RandomState>,
context: &B::Context,
) -> Result<B::Token, B::Error> { ... }
fn commit_token(
&mut self,
_processed_logits: &B::Logits,
_token: u32,
_context: &B::Context,
) -> Result<(), B::Error> { ... }
}Expand description
Sampling policy suitable for lossless speculative decoding.
Required Methods§
Provided Methods§
Sourcefn uses_checkpoint_defaults(&self) -> bool
fn uses_checkpoint_defaults(&self) -> bool
Whether loaded checkpoint defaults should wrap this policy.
Sourcefn supports_exact_optimistic_promotion(&self) -> bool
fn supports_exact_optimistic_promotion(&self) -> bool
Whether optimistic draft work is an exact discardable fork.
Sourcefn grammar_is_complete(&mut self) -> Result<bool, B::Error>
fn grammar_is_complete(&mut self) -> Result<bool, B::Error>
Whether the committed generation grammar is complete.
Sourcefn prefix_is_complete(&self, _history: &[u32]) -> Result<bool, B::Error>
fn prefix_is_complete(&self, _history: &[u32]) -> Result<bool, B::Error>
Whether an uncommitted logical prefix completes the grammar.
Sourcefn sample_processed(
&self,
logits: &B::Logits,
temperature: f32,
random: Option<&mut B::RandomState>,
context: &B::Context,
) -> Result<B::Token, B::Error>
fn sample_processed( &self, logits: &B::Logits, temperature: f32, random: Option<&mut B::RandomState>, context: &B::Context, ) -> Result<B::Token, B::Error>
Selects from already processed logits.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".