pub struct SamplingParams {
pub temperature: f32,
pub top_p: f32,
pub top_k: u32,
pub min_p: f32,
pub repetition_penalty: f32,
pub presence_penalty: f32,
pub frequency_penalty: f32,
pub stop_sequences: Vec<String>,
pub max_tokens: u32,
pub seed: Option<u64>,
}Expand description
Parameters controlling text generation sampling.
Fields§
§temperature: f32Temperature for sampling (0.0 = greedy, higher = more random). Default: 1.0
top_p: f32Top-p (nucleus) sampling threshold. Default: 1.0
top_k: u32Top-k sampling (0 = disabled). Default: 0
min_p: f32Minimum probability for min-p sampling (0.0 = disabled). Default: 0.0
repetition_penalty: f32Repetition penalty (1.0 = no penalty). Default: 1.0
presence_penalty: f32Presence penalty (-2.0 to 2.0). Default: 0.0
frequency_penalty: f32Frequency penalty (-2.0 to 2.0). Default: 0.0
stop_sequences: Vec<String>Stop sequences that halt generation.
max_tokens: u32Maximum number of tokens to generate. Default: 256
seed: Option<u64>Random seed for reproducibility.
Implementations§
Source§impl SamplingParams
impl SamplingParams
Sourcepub fn with_temperature(self, temperature: f32) -> Self
pub fn with_temperature(self, temperature: f32) -> Self
Sets the temperature.
Sourcepub fn with_top_p(self, top_p: f32) -> Self
pub fn with_top_p(self, top_p: f32) -> Self
Sets the top-p value.
Sourcepub fn with_top_k(self, top_k: u32) -> Self
pub fn with_top_k(self, top_k: u32) -> Self
Sets the top-k value.
Sourcepub fn with_max_tokens(self, max_tokens: u32) -> Self
pub fn with_max_tokens(self, max_tokens: u32) -> Self
Sets the maximum tokens.
Trait Implementations§
Source§impl Clone for SamplingParams
impl Clone for SamplingParams
Source§fn clone(&self) -> SamplingParams
fn clone(&self) -> SamplingParams
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 SamplingParams
impl Debug for SamplingParams
Source§impl Default for SamplingParams
impl Default for SamplingParams
Source§impl<'de> Deserialize<'de> for SamplingParams
impl<'de> Deserialize<'de> for SamplingParams
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SamplingParams
impl RefUnwindSafe for SamplingParams
impl Send for SamplingParams
impl Sync for SamplingParams
impl Unpin for SamplingParams
impl UnwindSafe for SamplingParams
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