pub struct ModelSamplingDefaults {
pub temperature: ModelSamplingDefault,
pub top_p: ModelSamplingDefault,
pub top_k: ModelSamplingDefault,
pub min_p: ModelSamplingDefault,
pub repeat_penalty: ModelSamplingDefault,
}Expand description
The sampler defaults one model declares.
Copy, and deliberately so: it rides ModelLaunchSpec into the resident
set and out again on every current_model() call, so it is cloned far more
often than it is built. Adding a String here would put an allocation on
the admission fast path and cost with_model_sampling its const.
Fields§
§temperature: ModelSamplingDefaultgeneral.sampling.temp.
top_p: ModelSamplingDefaultgeneral.sampling.top_p.
top_k: ModelSamplingDefaultgeneral.sampling.top_k.
min_p: ModelSamplingDefaultgeneral.sampling.min_p.
repeat_penalty: ModelSamplingDefaultgeneral.sampling.penalty_repeat.
Implementations§
Source§impl ModelSamplingDefaults
impl ModelSamplingDefaults
Sourcepub fn from_metadata<S: BuildHasher>(
metadata: &HashMap<String, String, S>,
) -> Self
pub fn from_metadata<S: BuildHasher>( metadata: &HashMap<String, String, S>, ) -> Self
Read what a model declares out of its stored GGUF metadata.
Values arrive stringified by GgufValue::to_string(), so a FLOAT32
0.7 is the string "0.7" — Rust’s Display prints the shortest form
that round-trips. Parsing it back yields 0.7, while /props reports
the same value widened from f32 (0.699999988079071); the ~1.2e-8 gap
is well inside the epsilon the comparison uses.
Sourcepub fn get(&self, field: &str) -> ModelSamplingDefault
pub fn get(&self, field: &str) -> ModelSamplingDefault
Look one field up by its gglib wire name.
Mirrors SlotParams::get so the baseline check reads both sides the
same way. A name with no GGUF key — presence_penalty,
dry_multiplier, or anything unknown — is Absent by
construction, not because this model happened not to set it.
Source§impl ModelSamplingDefaults
impl ModelSamplingDefaults
Sourcepub fn compare_field(
&self,
field: &str,
sending: Option<f64>,
) -> SamplingOverride
pub fn compare_field( &self, field: &str, sending: Option<f64>, ) -> SamplingOverride
Compare one field’s published value against what gglib will send.
sending is what the ladder resolved: None means gglib names the
field nowhere and llama.cpp is left to apply the model’s own value.
Sourcepub fn compare_all(
&self,
resolved: impl Fn(&str) -> Option<f64>,
) -> Vec<(&'static str, SamplingOverride)>
pub fn compare_all( &self, resolved: impl Fn(&str) -> Option<f64>, ) -> Vec<(&'static str, SamplingOverride)>
Compare every field a model can publish, in MODEL_SAMPLING_KEYS
order.
resolved looks each field up by its gglib wire name and returns what
the ladder decided to send, so callers hand in whichever config they are
explaining rather than this module learning about InferenceConfig.
Trait Implementations§
Source§impl Clone for ModelSamplingDefaults
impl Clone for ModelSamplingDefaults
Source§fn clone(&self) -> ModelSamplingDefaults
fn clone(&self) -> ModelSamplingDefaults
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 ModelSamplingDefaults
impl Debug for ModelSamplingDefaults
Source§impl Default for ModelSamplingDefaults
impl Default for ModelSamplingDefaults
Source§fn default() -> ModelSamplingDefaults
fn default() -> ModelSamplingDefaults
Source§impl PartialEq for ModelSamplingDefaults
impl PartialEq for ModelSamplingDefaults
Source§fn eq(&self, other: &ModelSamplingDefaults) -> bool
fn eq(&self, other: &ModelSamplingDefaults) -> bool
self and other values to be equal, and is used by ==.