Skip to main content

Answer

Enum Answer 

Source
pub enum Answer {
    Noul {
        noul: f64,
        raw_logprobs: BTreeMap<String, f64>,
        truncated: bool,
        truncated_labels: Vec<String>,
        label_mass: f64,
    },
    Choice {
        choice: String,
        index: usize,
        confidence: f64,
        probabilities: Vec<OptionProbability>,
        raw_logprobs: BTreeMap<String, f64>,
        truncated: bool,
        truncated_labels: Vec<String>,
        label_mass: f64,
    },
    Score {
        score: u8,
        expected_score: f64,
        legend: String,
        confidence: f64,
        probabilities: Vec<LevelProbability>,
        raw_logprobs: BTreeMap<String, f64>,
        truncated: bool,
        truncated_labels: Vec<String>,
        label_mass: f64,
    },
}
Expand description

A typed answer.

Every variant carries raw_logprobs, truncated and truncated_labels so a caller can redo the normalisation itself — calibration is a convenience here, never a place where information is lost.

A label in truncated_labels fell outside the host’s reporting window, so its entry in raw_logprobs is the weakest reported logprob: an upper bound, not an observation. truncated is true exactly when that list is not empty.

label_mass is how much of the model’s first-token probability fell on the offered labels, in 0.0..=1.0, counting only labels the host reported. The probabilities are normalised over the labels alone, so they look just as decisive when the model was about to write something else entirely and the letters were an afterthought at -8. Near 1 the model answered with a letter; well below it, the answer was read off tokens the model was not going to produce.

Variants§

§

Noul

Fields

§noul: f64

Probability that the answer is yes, in 0.0..=1.0.

§raw_logprobs: BTreeMap<String, f64>
§truncated: bool
§truncated_labels: Vec<String>
§label_mass: f64
§

Choice

Fields

§choice: String

The winning option, verbatim as it was supplied.

§index: usize

Its position in the request’s options.

§confidence: f64
§probabilities: Vec<OptionProbability>

Every option with its probability, in request order.

§raw_logprobs: BTreeMap<String, f64>
§truncated: bool
§truncated_labels: Vec<String>
§label_mass: f64
§

Score

Fields

§score: u8

The most likely level, 1-based.

§expected_score: f64

The probability-weighted mean level — often more useful than the argmax.

§legend: String

The legend entry for score.

§confidence: f64
§probabilities: Vec<LevelProbability>
§raw_logprobs: BTreeMap<String, f64>
§truncated: bool
§truncated_labels: Vec<String>
§label_mass: f64

Implementations§

Source§

impl Answer

Source

pub fn truncated(&self) -> bool

Whether some label fell outside the host’s top_logprobs window, making its probability an upper bound rather than an observation.

Source

pub fn truncated_labels(&self) -> &[String]

The labels whose logprob is a bound rather than an observation. Empty unless Answer::truncated.

Source

pub fn label_mass(&self) -> f64

How much of the model’s first-token probability fell on the offered labels. See Answer.

Source

pub fn confidence(&self) -> Option<f64>

How peaked the distribution is, in 0.0..=1.0. See cerno_core::math::confidence. None for a noul: as in JEV, its probability is already the whole answer.

Trait Implementations§

Source§

impl Clone for Answer

Source§

fn clone(&self) -> Answer

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 ComposeSchema for Answer

Source§

fn compose(generics: Vec<RefOr<Schema>>) -> RefOr<Schema>

Source§

impl Debug for Answer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Answer

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Answer

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl ToSchema for Answer

Source§

fn name() -> Cow<'static, str>

Return name of the schema. Read more
Source§

fn schemas(schemas: &mut Vec<(String, RefOr<Schema>)>)

Implement reference [utoipa::openapi::schema::Schema]s for this 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<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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

§

impl<T> PartialSchema for T
where T: ComposeSchema + ?Sized,

§

fn schema() -> RefOr<Schema>

Return ref or schema of implementing type that can then be used to construct combined schemas.
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.