pub struct Experiment { /* private fields */ }Expand description
An evaluation: a target run on every case of a dataset, a number of times, each run scored by every evaluator; the report goes to the sinks.
Each run is an eval.trial span (fields eval.experiment, eval.case,
eval.repetition) inside an eval.experiment span, and the target’s own
spans (an agent’s invoke_agent) nest in it. After scoring, each score is
a gen_ai.evaluation.result event on the trial span, with the
OpenTelemetry GenAI fields gen_ai.evaluation.name,
gen_ai.evaluation.score.value, gen_ai.evaluation.score.label (the
score’s label, else pass or fail). The explanation is the judge’s
text, which can quote the agent’s answer or the prompt, so it is recorded
only with record_content.
Implementations§
Source§impl Experiment
impl Experiment
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
An experiment named name: one repetition, four runs at a time.
Sourcepub fn evaluator(self, evaluator: impl Evaluator + 'static) -> Self
pub fn evaluator(self, evaluator: impl Evaluator + 'static) -> Self
Add an evaluator. Each one scores every run.
Sourcepub fn repetitions(self, repetitions: usize) -> Self
pub fn repetitions(self, repetitions: usize) -> Self
Run each case repetitions times, to measure how often a
nondeterministic target passes.
Sourcepub fn concurrency(self, concurrency: usize) -> Self
pub fn concurrency(self, concurrency: usize) -> Self
Run at most concurrency trials at a time (0 counts as 1).
Sourcepub fn threshold(self, evaluator: impl Into<String>, min_pass_rate: f64) -> Self
pub fn threshold(self, evaluator: impl Into<String>, min_pass_rate: f64) -> Self
The report passes only if evaluator passes at least min_pass_rate
(0 to 1) of the runs. Without one, an evaluator must pass every run.
Sourcepub fn record_content(self, record: bool) -> Self
pub fn record_content(self, record: bool) -> Self
Record each score’s explanation on its gen_ai.evaluation.result
event as gen_ai.evaluation.explanation. Off by default: the
explanation is the judge’s text, which can quote the agent’s answer or
the prompt, and telemetry is shared with the backend. The report keeps
the explanation either way.
Sourcepub fn trial_timeout(self, limit: Duration) -> Self
pub fn trial_timeout(self, limit: Duration) -> Self
Give each target run and each evaluator call at most limit. One
that takes longer fails and the other trials carry on: a target that
times out makes a trial with the error timed out after <n>s, which
the built-in evaluators fail; an evaluator that times out gives a
failed score labelled error. An agent target keeps the turns it
completed, as a failed turn does.
The limit is per trial, not per run, and per call: a trial with n
evaluators can take up to n + 1 times limit. The turns of one
multi-turn case share the one limit (a five-turn case gets one limit
in all, not five). A timed-out judge’s token usage is dropped, so the
report’s judge tokens undercount. A limit too large for the clock
(such as Duration::MAX) is no limit. Needs a running tokio runtime,
since the limit is a tokio::time timer. Off unless set.
Auto Trait Implementations§
impl !RefUnwindSafe for Experiment
impl !UnwindSafe for Experiment
impl Forget for Experiment
impl Freeze for Experimentwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<Case>: Freeze,
*const dyn Target is !null: Freeze,
PhantomData<dyn Target>: Freeze,
PhantomData<Box<dyn Evaluator>>: Freeze,
PhantomData<(String, f64)>: Freeze,
PhantomData<Box<dyn Sink>>: Freeze,
impl Move for Experiment
impl Send for Experiment
impl Sync for Experiment
impl Unpin for Experiment
impl UnsafeUnpin for Experimentwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Case>: UnsafeUnpin,
*const dyn Target is !null: UnsafeUnpin,
PhantomData<dyn Target>: UnsafeUnpin,
PhantomData<Box<dyn Evaluator>>: UnsafeUnpin,
PhantomData<(String, f64)>: UnsafeUnpin,
PhantomData<Box<dyn Sink>>: UnsafeUnpin,
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> 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> 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 more