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
impl ExplanationRequest
pub fn hosting(self, hosting: Hosting) -> Self
pub fn target(self, target: String) -> Self
pub fn control_factor(self, control_factor: f64) -> Self
pub fn contextual_control_threshold( self, contextual_control_threshold: f64, ) -> Self
pub fn control_log_additive(self, control_log_additive: bool) -> Self
pub fn postprocessing(self, postprocessing: Postprocessing) -> Self
pub fn normalize(self, normalize: bool) -> Self
pub fn prompt_granularity(self, prompt_granularity: PromptGranularity) -> Self
pub fn target_granularity(self, target_granularity: TargetGranularity) -> Self
pub fn control_token_overlap( self, control_token_overlap: ControlTokenOverlap, ) -> Self
Trait Implementations§
Source§impl Debug for ExplanationRequest
impl Debug for ExplanationRequest
Source§impl Default for ExplanationRequest
impl Default for ExplanationRequest
Source§fn default() -> ExplanationRequest
fn default() -> ExplanationRequest
Auto Trait Implementations§
impl Freeze for ExplanationRequest
impl RefUnwindSafe for ExplanationRequest
impl Send for ExplanationRequest
impl Sync for ExplanationRequest
impl Unpin for ExplanationRequest
impl UnwindSafe for ExplanationRequest
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> 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> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.