Struct google_api_proto::google::ai::generativelanguage::v1::GenerationConfig
source · pub struct GenerationConfig {
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>,
}
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.
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.
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
source§fn eq(&self, other: &GenerationConfig) -> bool
fn eq(&self, other: &GenerationConfig) -> bool
self
and other
values to be equal, and is used
by ==
.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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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::Request