pub struct SamplingParams {
pub temperature: f32,
pub top_p: f32,
pub min_p: f32,
pub top_k: usize,
pub repetition_penalty: f32,
pub penalty_last_n: usize,
pub presence_penalty: f32,
pub frequency_penalty: f32,
}Expand description
Sampling parameters for one generation request. temperature <= 0.0
means “sample nothing, take the greedy argmax” – the same
deterministic behavior ferrox always had before this module existed.
Fields§
§temperature: f32§top_p: f32Nucleus sampling threshold in (0.0, 1.0]. 1.0 disables top-p filtering (every token with nonzero probability is eligible).
min_p: f32Keep only candidates at least min_p times as likely as the most
likely one. 0.0 disables it; llama.cpp’s --min-p, whose
default is 0.05 (common/common.h:231) rather than off.
That default is why this is a parity item and not a feature: llama.cpp truncates with min-p on every run nobody configured, so without it ferrox could not reproduce llama.cpp’s own out-of-the-box output for any prompt.
The struct default here stays 0.0 (disabled) for the same
reason temperature defaults to greedy: SamplingParams::default
is ferrox’s “do nothing the caller did not ask for” baseline, and
llama.cpp’s CLI numbers live on the CLI flags.
top_k: usizeKeep only the top_k highest-probability tokens before
sampling. 0 disables top-k filtering.
repetition_penalty: f321.0 discourages repeating a token already in
history; 1.0 disables repetition penalty. Uses the standard convention (divide positive logits, multiply negative ones) so the penalty always pushes toward less likely, regardless of logit sign.
penalty_last_n: usizeHow many of the most recent tokens the penalties look at, as
llama.cpp’s penalty_last_n (common/common.h:238, default 64).
0 disables the penalties entirely. ferrox had no window at all
and scanned the WHOLE history, so on a long generation it
penalised a steadily growing set of tokens where llama.cpp
penalises the last 64 – the divergence grew with output length,
which is exactly when a repetition penalty matters most.
presence_penalty: f32OpenAI-style presence penalty: subtract from logits of tokens
that already appeared in history (once per distinct token).
frequency_penalty: f32OpenAI-style frequency penalty: subtract frequency_penalty * count from logits for each token id seen in history.
Trait Implementations§
Source§impl Clone for SamplingParams
impl Clone for SamplingParams
Source§fn clone(&self) -> SamplingParams
fn clone(&self) -> SamplingParams
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SamplingParams
impl Debug 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
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> ⓘ
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> ⓘ
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