struct Gemini::GenerationConfig
- Gemini::GenerationConfig
- Struct
- Value
- Object
Overview
Configuration options for model generation and outputs. Not all parameters are configurable for every model.
Included Modules
- JSON::Serializable
Defined in:
gemini/models.crConstructors
- .new(pull : JSON::PullParser)
- .new(candidate_count : Int32 | Nil = nil, stop_sequences : Nil | Array(String) = nil, temperature : Float64 | Nil = nil, max_output_tokens : Int32 | Nil = nil, top_k : Int32 | Nil = nil, top_p : Float64 | Nil = nil, response_mime_type : Nil | String = nil, response_schema : Nil | Gemini::Schema = nil, presence_penalty : Float64 | Nil = nil, frequency_penalty : Float64 | Nil = nil, response_logprobs : Bool | Nil = nil, logprobs : Int32 | Nil = nil)
Instance Method Summary
-
#candidate_count : Int32 | Nil
Number of generated responses to return.
-
#candidate_count=(candidate_count : Int32 | Nil)
Number of generated responses to return.
-
#frequency_penalty : Float64 | Nil
Frequency penalty applied to the next token's logprobs, multiplied by the number of times each token has been seen in the response so far.
-
#frequency_penalty=(frequency_penalty : Float64 | Nil)
Frequency penalty applied to the next token's logprobs, multiplied by the number of times each token has been seen in the response so far.
-
#logprobs : Int32 | Nil
Only valid if
#responseLogprobs
istrue
. -
#logprobs=(logprobs : Int32 | Nil)
Only valid if
#responseLogprobs
istrue
. -
#max_output_tokens : Int32 | Nil
The maximum number of tokens to include in a candidate.
-
#max_output_tokens=(max_output_tokens : Int32 | Nil)
The maximum number of tokens to include in a candidate.
-
#presence_penalty : Float64 | Nil
Presence penalty applied to the next token's logprobs if the token has already been seen in the response.
-
#presence_penalty=(presence_penalty : Float64 | Nil)
Presence penalty applied to the next token's logprobs if the token has already been seen in the response.
-
#response_logprobs=(response_logprobs : Bool | Nil)
If
true
, export the logprobs results in response. -
#response_logprobs? : Bool | Nil
If
true
, export the logprobs results in response. -
#response_mime_type : String | Nil
Output response mimetype of the generated candidate text.
-
#response_mime_type=(response_mime_type : String | Nil)
Output response mimetype of the generated candidate text.
-
#response_schema : Schema | Nil
Specifies the format of the JSON requested if response_mime_type is
application/json
. -
#response_schema=(response_schema : Schema | Nil)
Specifies the format of the JSON requested if response_mime_type is
application/json
. -
#stop_sequences : Array(String) | Nil
The set of character sequences (up to 5) that will stop output generation.
-
#stop_sequences=(stop_sequences : Array(String) | Nil)
The set of character sequences (up to 5) that will stop output generation.
-
#temperature : Float64 | Nil
Controls the randomness of the output.
-
#temperature=(temperature : Float64 | Nil)
Controls the randomness of the output.
-
#top_k : Int32 | Nil
The maximum number of tokens to consider when sampling.
-
#top_k=(top_k : Int32 | Nil)
The maximum number of tokens to consider when sampling.
-
#top_p : Float64 | Nil
The maximum cumulative probability of tokens to consider when sampling.
-
#top_p=(top_p : Float64 | Nil)
The maximum cumulative probability of tokens to consider when sampling.
Constructor Detail
Instance Method Detail
Frequency penalty applied to the next token's logprobs, multiplied by the number of times each token has been seen in the response so far. (Optional) 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 maxOutputTokens limit: "...the the the the the...".
Frequency penalty applied to the next token's logprobs, multiplied by the number of times each token has been seen in the response so far. (Optional) 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 maxOutputTokens limit: "...the the the the the...".
Only valid if #responseLogprobs
is true
. This sets the number of top logprobs to return at each decoding
step in the Candidate#logprobs_result
. (Optional)
Only valid if #responseLogprobs
is true
. This sets the number of top logprobs to return at each decoding
step in the Candidate#logprobs_result
. (Optional)
The maximum number of tokens to include in a candidate. If unset, this will default to output_token_limit specified in the model's specification.
The maximum number of tokens to include in a candidate. If unset, this will default to output_token_limit specified in the model's specification.
Presence penalty applied to the next token's logprobs if the token has already been seen in the response. (Optional) This penalty is binary on/off and not dependant on the number of times the token is used (after the first). Use frequencyPenalty 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.
Presence penalty applied to the next token's logprobs if the token has already been seen in the response. (Optional) This penalty is binary on/off and not dependant on the number of times the token is used (after the first). Use frequencyPenalty 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.
If true
, export the logprobs results in response. (Optional)
Output response mimetype of the generated candidate text. Supported mimetype:
- text/plain: (default) Text output.
- application/json: JSON response in the candidates.
Output response mimetype of the generated candidate text. Supported mimetype:
- text/plain: (default) Text output.
- application/json: JSON response in the candidates.
Specifies the format of the JSON requested if response_mime_type is application/json
.
Specifies the format of the JSON requested if response_mime_type is application/json
.
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.
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.
Controls the randomness of the output.
Values can range from [0.0,1.0]
, inclusive. A value closer to 1.0
will produce responses that are more
varied and creative, while a value closer to 0.0
will typically result in more straightforward responses from
the model.
Controls the randomness of the output.
Values can range from [0.0,1.0]
, inclusive. A value closer to 1.0
will produce responses that are more
varied and creative, while a value closer to 0.0
will typically result in more straightforward responses from
the model.
The maximum number of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Top-k sampling considers the set of top_k most probable tokens. Defaults to 40.
The maximum number of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Top-k sampling considers the set of top_k most probable tokens. Defaults to 40.
The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and 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 number of tokens based on the cumulative probability.
The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and 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 number of tokens based on the cumulative probability.