Struct ExplanationRequest

Source
pub struct ExplanationRequest {
    pub model: String,
    pub hosting: Option<Hosting>,
    pub prompt: Prompt,
    pub target: Option<String>,
    pub control_factor: Option<f64>,
    pub contextual_control_threshold: Option<f64>,
    pub control_log_additive: Option<bool>,
    pub postprocessing: Option<Postprocessing>,
    pub normalize: Option<bool>,
    pub prompt_granularity: Option<PromptGranularity>,
    pub target_granularity: Option<TargetGranularity>,
    pub control_token_overlap: Option<ControlTokenOverlap>,
}

Fields§

§model: String

Name of the model to use.

§hosting: Option<Hosting>

Determines in which datacenters the request may be processed. You can either set the parameter to “aleph-alpha” or omit it (defaulting to None).

Not setting this value, or setting it to None, gives us maximal flexibility in processing your request in our own datacenters and on servers hosted with other providers. Choose this option for maximal availability.

Setting it to “aleph-alpha” allows us to only process the request in our own datacenters. Choose this option for maximal data privacy.

§prompt: Prompt§target: Option<String>

The completion string to be explained based on model probabilities.

§control_factor: Option<f64>

Factor to apply to the given token in the attention matrix.

  • 0 <= factor < 1 => Suppress the given token
  • factor == 1 => identity operation, no change to attention
  • factor > 1 => Amplify the given token
§contextual_control_threshold: Option<f64>

If set to null, attention control parameters only apply to those tokens that have explicitly been set in the request. If set to a non-null value, we apply the control parameters to similar tokens as well. Controls that have been applied to one token will then be applied to all other tokens that have at least the similarity score defined by this parameter. The similarity score is the cosine similarity of token embeddings.

§control_log_additive: Option<bool>

true: apply controls on prompt items by adding the log(control_factor) to attention scores. false: apply controls on prompt items by (attention_scores - -attention_scores.min(-1)) * control_factor

§postprocessing: Option<Postprocessing>

Optionally apply postprocessing to the difference in cross entropy scores for each token. “none”: Apply no postprocessing. “absolute”: Return the absolute value of each value. “square”: Square each value

§normalize: Option<bool>

Return normalized scores. Minimum score becomes 0 and maximum score becomes 1. Applied after any postprocessing

§prompt_granularity: Option<PromptGranularity>

At which granularity should the target be explained in terms of the prompt. If you choose, for example, “sentence” then we report the importance score of each sentence in the prompt towards generating the target output.

If you do not choose a granularity then we will try to find the granularity that brings you closest to around 30 explanations. For large documents, this would likely be sentences. For short prompts this might be individual words or even tokens.

If you choose a custom granularity then you must provide a custom delimiter. We then split your prompt by that delimiter. This might be helpful if you are using few-shot prompts that contain stop sequences.

For image prompt items, the granularities determine into how many tiles we divide the image for the explanation. Token -> 12x12 Word -> 6x6 Sentence -> 3x3 Paragraph -> 1

§target_granularity: Option<TargetGranularity>

How many explanations should be returned in the output.

Complete -> Return one explanation for the entire target. Helpful in many cases to determine which parts of the prompt contribute overall to the given completion. Token -> Return one explanation for each token in the target.

§control_token_overlap: Option<ControlTokenOverlap>

What to do if a control partially overlaps with a text or image token.

If set to “partial”, the factor will be adjusted proportionally with the amount of the token it overlaps. So a factor of 2.0 of a control that only covers 2 of 4 token characters, would be adjusted to 1.5. (It always moves closer to 1, since 1 is an identity operation for control factors.)

If set to “complete”, the full factor will be applied as long as the control overlaps with the token at all.

Implementations§

Source§

impl ExplanationRequest

Source

pub fn hosting(self, hosting: Hosting) -> Self

Source

pub fn target(self, target: String) -> Self

Source

pub fn control_factor(self, control_factor: f64) -> Self

Source

pub fn contextual_control_threshold( self, contextual_control_threshold: f64, ) -> Self

Source

pub fn control_log_additive(self, control_log_additive: bool) -> Self

Source

pub fn postprocessing(self, postprocessing: Postprocessing) -> Self

Source

pub fn normalize(self, normalize: bool) -> Self

Source

pub fn prompt_granularity(self, prompt_granularity: PromptGranularity) -> Self

Source

pub fn target_granularity(self, target_granularity: TargetGranularity) -> Self

Source

pub fn control_token_overlap( self, control_token_overlap: ControlTokenOverlap, ) -> Self

Trait Implementations§

Source§

impl Debug for ExplanationRequest

Source§

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

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

impl Default for ExplanationRequest

Source§

fn default() -> ExplanationRequest

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

impl Serialize for ExplanationRequest

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

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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.
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
Source§

impl<T> ErasedDestructor for T
where T: 'static,