Skip to main content

Evaluation

Struct Evaluation 

Source
pub struct Evaluation { /* private fields */ }
Expand description

RubyLLM::Evaluation: a reusable evaluation. Clone it to reuse a definition; use Evaluation::subclass for Ruby’s Class.new(parent).

Implementations§

Source§

impl Evaluation

Source

pub fn new() -> Evaluation

An anonymous evaluation (Class.new(RubyLLM::Evaluation)): it needs an explicit dataset.

Source

pub fn named(name: impl Into<String>) -> Evaluation

class SupportEvaluation < RubyLLM::Evaluation: the name reports carry and dataset discovery uses (SupportEvaluation reads app/evals/support_evaluation.yml).

Source

pub fn subclass(&self) -> Evaluation

Class.new(parent): an anonymous child inheriting the dataset, evaluator, criteria, adapters, and hooks. The child may redeclare an inherited criterion; the parent is unchanged.

Source

pub fn name(&self) -> Option<&str>

The evaluation’s name, if it has one.

Source

pub fn with_config(&mut self, config: Arc<Config>) -> &mut Self

Use this configuration for events, the default evaluator model, and its requests.

Source

pub fn dataset(&mut self, source: impl Into<Dataset>) -> &mut Self

dataset(source): a path, cases, data, or Dataset::block.

Source

pub fn dataset_source(&self) -> Option<&Dataset>

dataset with no argument: the configured source, if any.

Source

pub fn evaluator(&mut self, evaluator: Evaluator) -> &mut Self

evaluator target, **options: the default evaluator for every criterion.

Source

pub fn without_evaluator(&mut self) -> &mut Self

evaluator false: no model grading; only assertions run.

Source

pub fn current_evaluator(&self) -> Option<&Evaluator>

evaluator: the class evaluator, or None when grading is disabled.

Source

pub fn evaluation( &mut self, name: impl Into<String>, instructions: Option<&str>, ) -> Result<&mut Self>

evaluation name, instructions: a semantic criterion. Declared criteria replace implicit correctness; evaluation(:correctness) without instructions includes the built-in comparison. None instructions set a policy on a question a Judge already defines.

Source

pub fn evaluation_with( &mut self, name: impl Into<String>, instructions: Option<&str>, minimum: Option<f64>, evaluator: Option<Evaluator>, ) -> Result<&mut Self>

evaluation name, instructions, minimum:, evaluator:. A minimum applies to a native probability or score; evaluator overrides the class evaluator for this criterion.

Source

pub fn definitions(&self) -> Vec<(String, Option<String>, Option<f64>)>

definitions: (name, instructions, minimum) for every declared criterion.

Source

pub fn adapt<T: Any + Send + Sync>( &mut self, f: impl Fn(&T) -> Value + Send + Sync + 'static, ) -> &mut Self

adapt Type { |value| ... }: converts a custom result into evaluation evidence. The original stays available as the trial’s result.

Source

pub fn adapter_count(&self) -> usize

adapters: how many are declared.

Source

pub fn perform<F, Fut>(&mut self, f: F) -> &mut Self
where F: Fn(Instance) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Outcome, Failure>> + Send + 'static,

def perform(input): runs the application under evaluation.

Source

pub fn assertions( &mut self, f: impl Fn(&mut Assertions<'_>) -> Result<(), Failure> + Send + Sync + 'static, ) -> &mut Self

def assertions: runs after perform, with the Minitest-style assertion family.

Source

pub fn clear_assertions(&mut self) -> &mut Self

Removes the assertions hook (def assertions; end).

Source

pub fn setup<F, Fut>(&mut self, f: F) -> &mut Self
where F: Fn(Instance) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<(), Failure>> + Send + 'static,

def setup: runs before perform on each fresh case instance.

Source

pub fn teardown<F, Fut>(&mut self, f: F) -> &mut Self
where F: Fn(Instance) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<(), Failure>> + Send + 'static,

def teardown: runs after each case, even when setup, perform, or an assertion fails.

Source

pub fn cases( &self, dataset: Option<&Dataset>, only: Option<&[String]>, ) -> Result<Vec<Case>>

cases(dataset:, only:): the dataset cases, without running anything. only selects case names and fails when any is missing (or none is given).

Source

pub async fn run(&self) -> Result<Report>

run: every case once, with the configured dataset.

Source

pub async fn run_with(&self, options: RunOptions) -> Result<Report>

run(dataset:, only:, repetitions:, id:).

Source

pub async fn run_each<F, Fut>( &self, options: RunOptions, on_trial: F, ) -> Result<Report>
where F: FnMut(&Trial) -> Fut + Send, Fut: Future<Output = Result<()>> + Send,

run(...) { |trial| ... }: on_trial receives each completed trial before the next case starts, and the future it returns runs to completion first; its error ends the run and is returned. Configuration errors return before any case runs; task, assertion, and evaluator failures are recorded per trial.

Trait Implementations§

Source§

impl Clone for Evaluation

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Evaluation

Source§

fn default() -> Evaluation

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more