#[non_exhaustive]pub struct SamplingParams {
pub top_p: f32,
pub top_k: i32,
pub min_p: f32,
pub presence_penalty: f32,
pub repetition_penalty: f32,
}Expand description
Sampling parameters that control token generation.
Marked #[non_exhaustive] so future sampling knobs can be added without
a breaking release. Start from SamplingParams::default and chain
with_* setters:
let params = rig_llama_cpp::SamplingParams::default()
.with_top_k(40)
.with_presence_penalty(1.5);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.top_p: f32Nucleus sampling threshold (default: 0.95).
top_k: i32Top-k sampling parameter (default: 40).
min_p: f32Minimum probability threshold (default: 0.0).
presence_penalty: f32Penalty for token presence (default: 0.0).
repetition_penalty: f32Penalty for token repetition (default: 1.0).
Implementations§
Source§impl SamplingParams
impl SamplingParams
Sourcepub fn with_top_p(self, top_p: f32) -> Self
pub fn with_top_p(self, top_p: f32) -> Self
Set the nucleus sampling threshold.
Sourcepub fn with_top_k(self, top_k: i32) -> Self
pub fn with_top_k(self, top_k: i32) -> Self
Set the top-k sampling parameter.
Sourcepub fn with_min_p(self, min_p: f32) -> Self
pub fn with_min_p(self, min_p: f32) -> Self
Set the minimum probability threshold.
Sourcepub fn with_presence_penalty(self, presence_penalty: f32) -> Self
pub fn with_presence_penalty(self, presence_penalty: f32) -> Self
Set the presence penalty.
Sourcepub fn with_repetition_penalty(self, repetition_penalty: f32) -> Self
pub fn with_repetition_penalty(self, repetition_penalty: f32) -> Self
Set the repetition penalty.
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 (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 SamplingParams
impl Debug for SamplingParams
Source§impl Default for SamplingParams
impl Default for SamplingParams
impl Copy for SamplingParams
Auto Trait Implementations§
impl Freeze for SamplingParams
impl RefUnwindSafe for SamplingParams
impl Send for SamplingParams
impl Sync for SamplingParams
impl Unpin for SamplingParams
impl UnsafeUnpin 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