pub struct ConfigSnapshot {
pub temperature: f64,
pub top_p: f64,
pub top_k: f64,
pub frequency_penalty: f64,
pub presence_penalty: f64,
pub retrieval_top_k: f64,
pub similarity_threshold: f64,
pub temporal_decay: f64,
}Expand description
Snapshot of all tunable parameters for a single experiment arm.
ConfigSnapshot is the bridge between Zeph’s runtime Config and the
variation engine. Each experiment arm is defined by a snapshot derived from
the baseline config with exactly one parameter changed via Self::apply.
The snapshot is also used to extract GenerationOverrides that are passed
to the subject provider for a candidate evaluation.
§Examples
use zeph_experiments::{ConfigSnapshot, ParameterKind, Variation, VariationValue};
let baseline = ConfigSnapshot::default();
let variation = Variation {
parameter: ParameterKind::Temperature,
value: VariationValue::from(0.9_f64),
};
let candidate = baseline.apply(&variation);
assert!((candidate.temperature - 0.9).abs() < f64::EPSILON);
assert!((candidate.top_p - baseline.top_p).abs() < f64::EPSILON); // unchanged
// Round-trip through diff
let recovered = baseline.diff(&candidate).unwrap();
assert_eq!(recovered.parameter, ParameterKind::Temperature);Fields§
§temperature: f64LLM sampling temperature.
top_p: f64Top-p (nucleus) sampling probability.
top_k: f64Top-k sampling cutoff (stored as f64 to match the search space representation).
frequency_penalty: f64Frequency penalty applied to already-seen tokens.
presence_penalty: f64Presence penalty applied to already-seen topics.
retrieval_top_k: f64Number of memory chunks to retrieve per query.
similarity_threshold: f64Minimum cosine similarity for cross-session memory recall.
temporal_decay: f64Half-life in days for temporal memory decay.
Implementations§
Source§impl ConfigSnapshot
impl ConfigSnapshot
Sourcepub fn from_config(config: &Config) -> Self
pub fn from_config(config: &Config) -> Self
Create a snapshot from the current runtime config.
LLM generation parameters come from config.llm.candle.generation when
a Candle provider is configured. All other providers do not expose
generation params in config — defaults are used for the experiment baseline.
Memory parameters are read from config.memory.semantic.
Sourcepub fn apply(&self, variation: &Variation) -> Self
pub fn apply(&self, variation: &Variation) -> Self
Apply a single variation and return a new snapshot with that parameter changed.
Sourcepub fn diff(&self, other: &ConfigSnapshot) -> Option<Variation>
pub fn diff(&self, other: &ConfigSnapshot) -> Option<Variation>
Return the single Variation that differs between self and other, or None
if zero or more than one parameter differs.
Integer parameters (TopK, RetrievalTopK) produce a VariationValue::Int variant.
Sourcepub fn get(&self, kind: ParameterKind) -> f64
pub fn get(&self, kind: ParameterKind) -> f64
Get the current value of a parameter by kind.
Unknown kinds (from #[non_exhaustive] additions) return 0.0.
§Examples
use zeph_experiments::{ConfigSnapshot, ParameterKind};
let s = ConfigSnapshot::default();
assert!((s.get(ParameterKind::Temperature) - 0.7).abs() < f64::EPSILON);
assert!((s.get(ParameterKind::TopK) - 40.0).abs() < f64::EPSILON);Sourcepub fn set(&mut self, kind: ParameterKind, value: f64)
pub fn set(&mut self, kind: ParameterKind, value: f64)
Set the value of a parameter by kind.
Unknown kinds (from #[non_exhaustive] additions) are silently ignored.
§Examples
use zeph_experiments::{ConfigSnapshot, ParameterKind};
let mut s = ConfigSnapshot::default();
s.set(ParameterKind::Temperature, 1.2);
assert!((s.temperature - 1.2).abs() < f64::EPSILON);Sourcepub fn to_generation_overrides(&self) -> GenerationOverrides
pub fn to_generation_overrides(&self) -> GenerationOverrides
Extract LLM-relevant parameter overrides for use by the experiment engine.
Uses .round() as usize for top_k to avoid truncation from floating-point noise.
Trait Implementations§
Source§impl Clone for ConfigSnapshot
impl Clone for ConfigSnapshot
Source§fn clone(&self) -> ConfigSnapshot
fn clone(&self) -> ConfigSnapshot
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConfigSnapshot
impl Debug for ConfigSnapshot
Source§impl Default for ConfigSnapshot
impl Default for ConfigSnapshot
Source§impl<'de> Deserialize<'de> for ConfigSnapshot
impl<'de> Deserialize<'de> for ConfigSnapshot
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>,
Auto Trait Implementations§
impl Freeze for ConfigSnapshot
impl RefUnwindSafe for ConfigSnapshot
impl Send for ConfigSnapshot
impl Sync for ConfigSnapshot
impl Unpin for ConfigSnapshot
impl UnsafeUnpin for ConfigSnapshot
impl UnwindSafe for ConfigSnapshot
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request