pub struct SamplerConfig {
pub temperature: f32,
pub top_k: u32,
pub top_p: f32,
pub repeat_penalty: f32,
pub freq_penalty: f32,
pub presence_penalty: f32,
pub penalty_window: u32,
pub seed: u64,
}Expand description
Sampling parameters. temperature <= 0.0 ⇒ greedy argmax (all other fields ignored).
The canonical wire form is a CBOR map (the project’s CBOR-first payload substrate) — see
SamplerConfig::to_cbor / SamplerConfig::from_cbor. Transports that are JSON-enveloped
(e.g. the MCP boundary) carry it as a hex-encoded CBOR blob, decoded via the existing JSON
string helper — no ad-hoc per-field JSON float parsing.
Fields§
§temperature: f32Softmax temperature. <= 0.0 selects greedy argmax (the pre-W2 default behaviour).
top_k: u32Keep only the top_k highest-logit tokens (0 ⇒ no top-k limit).
top_p: f32Nucleus threshold in (0.0, 1.0]; keep the smallest set whose cumulative prob ≥ top_p
(>= 1.0 ⇒ no top-p limit).
repeat_penalty: f32Multiplicative penalty on logits of tokens present in the penalty window (1.0 ⇒ none).
freq_penalty: f32Additive penalty per prior occurrence in the window (subtracted from the logit).
presence_penalty: f32Additive penalty for any presence in the window (subtracted once).
penalty_window: u32Number of most-recent context tokens the penalties consider (0 ⇒ whole context).
seed: u64PRNG seed — fixed seed ⇒ reproducible draws.
Implementations§
Source§impl SamplerConfig
impl SamplerConfig
Sourcepub fn to_cbor(&self) -> Vec<u8> ⓘ
pub fn to_cbor(&self) -> Vec<u8> ⓘ
Encode as a CBOR map (the canonical payload form). Infallible for this fixed scalar schema.
Sourcepub fn from_cbor(bytes: &[u8]) -> Option<Self>
pub fn from_cbor(bytes: &[u8]) -> Option<Self>
Decode from a CBOR map payload. Returns None on malformed CBOR or a schema mismatch —
the caller then keeps greedy decode rather than sampling on a bad config.
Sourcepub fn chat_default() -> Self
pub fn chat_default() -> Self
A sensible default for interactive chat / instruct generation: enough randomness to avoid the greedy repetition-collapse, plus a light repeat penalty, while staying reproducible (fixed seed). Benchmarks and determinism tests must NOT install this — the unconfigured global stays greedy, preserving the bit-exact a1a/a6a guarantees.
Trait Implementations§
Source§impl Clone for SamplerConfig
impl Clone for SamplerConfig
Source§fn clone(&self) -> SamplerConfig
fn clone(&self) -> SamplerConfig
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 SamplerConfig
impl Debug for SamplerConfig
Source§impl Default for SamplerConfig
impl Default for SamplerConfig
Source§impl<'de> Deserialize<'de> for SamplerConfig
impl<'de> Deserialize<'de> for SamplerConfig
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>,
Source§impl Serialize for SamplerConfig
impl Serialize for SamplerConfig
impl Copy for SamplerConfig
Auto Trait Implementations§
impl Freeze for SamplerConfig
impl RefUnwindSafe for SamplerConfig
impl Send for SamplerConfig
impl Sync for SamplerConfig
impl Unpin for SamplerConfig
impl UnsafeUnpin for SamplerConfig
impl UnwindSafe for SamplerConfig
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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