pub struct GenerationConfig {Show 15 fields
pub candidate_count: Option<i32>,
pub stop_sequences: Vec<String>,
pub max_output_tokens: Option<i32>,
pub temperature: Option<f32>,
pub top_p: Option<f32>,
pub top_k: Option<i32>,
pub response_mime_type: String,
pub response_schema: Option<Schema>,
pub presence_penalty: Option<f32>,
pub frequency_penalty: Option<f32>,
pub response_logprobs: Option<bool>,
pub logprobs: Option<i32>,
pub enable_enhanced_civic_answers: Option<bool>,
pub response_modalities: Vec<i32>,
pub speech_config: Option<SpeechConfig>,
}
Expand description
Configuration options for model generation and outputs. Not all parameters are configurable for every model.
Fields§
§candidate_count: Option<i32>
Optional. Number of generated responses to return.
Currently, this value can only be set to 1. If unset, this will default to 1.
stop_sequences: Vec<String>
Optional. The set of character sequences (up to 5) that will stop output
generation. If specified, the API will stop at the first appearance of a
stop_sequence
. The stop sequence will not be included as part of the
response.
max_output_tokens: Option<i32>
Optional. The maximum number of tokens to include in a response candidate.
Note: The default value varies by model, see the Model.output_token_limit
attribute of the Model
returned from the getModel
function.
temperature: Option<f32>
Optional. Controls the randomness of the output.
Note: The default value varies by model, see the Model.temperature
attribute of the Model
returned from the getModel
function.
Values can range from [0.0, 2.0].
top_p: Option<f32>
Optional. The maximum cumulative probability of tokens to consider when sampling.
The model uses combined Top-k and Top-p (nucleus) sampling.
Tokens are sorted based on their assigned probabilities so that only the most likely tokens are considered. Top-k sampling directly limits the maximum number of tokens to consider, while Nucleus sampling limits the number of tokens based on the cumulative probability.
Note: The default value varies by Model
and is specified by
theModel.top_p
attribute returned from the getModel
function. An empty
top_k
attribute indicates that the model doesn’t apply top-k sampling
and doesn’t allow setting top_k
on requests.
top_k: Option<i32>
Optional. The maximum number of tokens to consider when sampling.
Gemini models use Top-p (nucleus) sampling or a combination of Top-k and
nucleus sampling. Top-k sampling considers the set of top_k
most probable
tokens. Models running with nucleus sampling don’t allow top_k setting.
Note: The default value varies by Model
and is specified by
theModel.top_p
attribute returned from the getModel
function. An empty
top_k
attribute indicates that the model doesn’t apply top-k sampling
and doesn’t allow setting top_k
on requests.
response_mime_type: String
Optional. MIME type of the generated candidate text.
Supported MIME types are:
text/plain
: (default) Text output.
application/json
: JSON response in the response candidates.
text/x.enum
: ENUM as a string response in the response candidates.
Refer to the
docs
for a list of all supported text MIME types.
response_schema: Option<Schema>
Optional. Output schema of the generated candidate text. Schemas must be a subset of the OpenAPI schema and can be objects, primitives or arrays.
If set, a compatible response_mime_type
must also be set.
Compatible MIME types:
application/json
: Schema for JSON response.
Refer to the JSON text generation
guide for more details.
presence_penalty: Option<f32>
Optional. Presence penalty applied to the next token’s logprobs if the token has already been seen in the response.
This penalty is binary on/off and not dependant on the number of times the token is used (after the first). Use [frequency_penalty][google.ai.generativelanguage.v1beta.GenerationConfig.frequency_penalty] for a penalty that increases with each use.
A positive penalty will discourage the use of tokens that have already been used in the response, increasing the vocabulary.
A negative penalty will encourage the use of tokens that have already been used in the response, decreasing the vocabulary.
frequency_penalty: Option<f32>
Optional. Frequency penalty applied to the next token’s logprobs, multiplied by the number of times each token has been seen in the respponse so far.
A positive penalty will discourage the use of tokens that have already been used, proportional to the number of times the token has been used: The more a token is used, the more dificult it is for the model to use that token again increasing the vocabulary of responses.
Caution: A negative penalty will encourage the model to reuse tokens proportional to the number of times the token has been used. Small negative values will reduce the vocabulary of a response. Larger negative values will cause the model to start repeating a common token until it hits the [max_output_tokens][google.ai.generativelanguage.v1beta.GenerationConfig.max_output_tokens] limit.
response_logprobs: Option<bool>
Optional. If true, export the logprobs results in response.
logprobs: Option<i32>
Optional. Only valid if [response_logprobs=True][google.ai.generativelanguage.v1beta.GenerationConfig.response_logprobs]. This sets the number of top logprobs to return at each decoding step in the [Candidate.logprobs_result][google.ai.generativelanguage.v1beta.Candidate.logprobs_result].
enable_enhanced_civic_answers: Option<bool>
Optional. Enables enhanced civic answers. It may not be available for all models.
response_modalities: Vec<i32>
Optional. The requested modalities of the response. Represents the set of modalities that the model can return, and should be expected in the response. This is an exact match to the modalities of the response.
A model may have multiple combinations of supported modalities. If the requested modalities do not match any of the supported combinations, an error will be returned.
An empty list is equivalent to requesting only text.
speech_config: Option<SpeechConfig>
Optional. The speech generation config.
Implementations§
Source§impl GenerationConfig
impl GenerationConfig
Sourcepub fn candidate_count(&self) -> i32
pub fn candidate_count(&self) -> i32
Returns the value of candidate_count
, or the default value if candidate_count
is unset.
Sourcepub fn max_output_tokens(&self) -> i32
pub fn max_output_tokens(&self) -> i32
Returns the value of max_output_tokens
, or the default value if max_output_tokens
is unset.
Sourcepub fn temperature(&self) -> f32
pub fn temperature(&self) -> f32
Returns the value of temperature
, or the default value if temperature
is unset.
Sourcepub fn presence_penalty(&self) -> f32
pub fn presence_penalty(&self) -> f32
Returns the value of presence_penalty
, or the default value if presence_penalty
is unset.
Sourcepub fn frequency_penalty(&self) -> f32
pub fn frequency_penalty(&self) -> f32
Returns the value of frequency_penalty
, or the default value if frequency_penalty
is unset.
Sourcepub fn response_logprobs(&self) -> bool
pub fn response_logprobs(&self) -> bool
Returns the value of response_logprobs
, or the default value if response_logprobs
is unset.
Sourcepub fn logprobs(&self) -> i32
pub fn logprobs(&self) -> i32
Returns the value of logprobs
, or the default value if logprobs
is unset.
Sourcepub fn enable_enhanced_civic_answers(&self) -> bool
pub fn enable_enhanced_civic_answers(&self) -> bool
Returns the value of enable_enhanced_civic_answers
, or the default value if enable_enhanced_civic_answers
is unset.
Sourcepub fn response_modalities(
&self,
) -> FilterMap<Cloned<Iter<'_, i32>>, fn(i32) -> Option<Modality>>
pub fn response_modalities( &self, ) -> FilterMap<Cloned<Iter<'_, i32>>, fn(i32) -> Option<Modality>>
Returns an iterator which yields the valid enum values contained in response_modalities
.
Sourcepub fn push_response_modalities(&mut self, value: Modality)
pub fn push_response_modalities(&mut self, value: Modality)
Appends the provided enum value to response_modalities
.
Trait Implementations§
Source§impl Clone for GenerationConfig
impl Clone for GenerationConfig
Source§fn clone(&self) -> GenerationConfig
fn clone(&self) -> GenerationConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for GenerationConfig
impl Debug for GenerationConfig
Source§impl Default for GenerationConfig
impl Default for GenerationConfig
Source§impl Message for GenerationConfig
impl Message for GenerationConfig
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
. Read moreSource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
.Source§impl PartialEq for GenerationConfig
impl PartialEq for GenerationConfig
impl StructuralPartialEq for GenerationConfig
Auto Trait Implementations§
impl Freeze for GenerationConfig
impl RefUnwindSafe for GenerationConfig
impl Send for GenerationConfig
impl Sync for GenerationConfig
impl Unpin for GenerationConfig
impl UnwindSafe for GenerationConfig
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic_veecore::Request