pub struct StandardSampler { /* private fields */ }Expand description
Selects a token after applying multiple SamplerStage’s to the
probability distribution output by the model.
Implementations§
Source§impl StandardSampler
impl StandardSampler
Sourcepub fn new_softmax(
stages: Vec<SamplerStage>,
min_keep: usize,
) -> StandardSampler
pub fn new_softmax( stages: Vec<SamplerStage>, min_keep: usize, ) -> StandardSampler
Creates a new StandardSampler that modifies the model’s raw
distribution using multiple SamplerStage’s, then selects a random
token from that distrubution.
Ensures that at least min_keep tokens remain after the
SamplerStage’s are applied.
Sourcepub fn new_greedy() -> StandardSampler
pub fn new_greedy() -> StandardSampler
Creates a new StandardSampler that always selects the next most
token produced by the model.
Sourcepub fn new_mirostat(
stages: Vec<SamplerStage>,
min_keep: usize,
tau: f32,
eta: f32,
m: i32,
) -> StandardSampler
pub fn new_mirostat( stages: Vec<SamplerStage>, min_keep: usize, tau: f32, eta: f32, m: i32, ) -> StandardSampler
Creates a new StandardSampler that selects a token using
Mirostat.
Sourcepub fn new_mirostat_v2(
stages: Vec<SamplerStage>,
min_keep: usize,
tau: f32,
eta: f32,
) -> StandardSampler
pub fn new_mirostat_v2( stages: Vec<SamplerStage>, min_keep: usize, tau: f32, eta: f32, ) -> StandardSampler
Creates a new StandardSampler that selects a token using
Mirostat V2.
Trait Implementations§
Source§impl Clone for StandardSampler
impl Clone for StandardSampler
Source§fn clone(&self) -> StandardSampler
fn clone(&self) -> StandardSampler
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 StandardSampler
impl Debug for StandardSampler
Source§impl Default for StandardSampler
impl Default for StandardSampler
Source§impl Sampler for StandardSampler
impl Sampler for StandardSampler
Source§fn sample(
&mut self,
context: *mut llama_context,
tokens: &[Token],
candidates_p: llama_token_data_array,
) -> Token
fn sample( &mut self, context: *mut llama_context, tokens: &[Token], candidates_p: llama_token_data_array, ) -> Token
Given a
llama_context, the tokens in context (to allow for
repetition penalities), and a llama_token_data_array (which contains
the distribution over the next token as output by the model), selects a
token.Auto Trait Implementations§
impl Freeze for StandardSampler
impl RefUnwindSafe for StandardSampler
impl Send for StandardSampler
impl Sync for StandardSampler
impl Unpin for StandardSampler
impl UnsafeUnpin for StandardSampler
impl UnwindSafe for StandardSampler
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