Understand and configure model parameters

Each call that you send to a model includes parameter values that control how the model generates a response. The model can generate different results for different parameter values. Experiment with different parameter values to get the best values for the task. The parameters available for different models may differ.

Jump to Gemini parameters Jump to Imagen parameters

Parameters for Gemini models

Learn about parameters available for use with Gemini models, including how to configure them.

The configuration is maintained for the lifetime of the initialized Vertex AI service and model instance. To update model configuration, the model instance must be re-initialized.

Description of each parameter

The most common parameters are the following:

Learn about each of these parameters in the following sections of this page.

Max output tokens

Maximum number of tokens that can be generated in the response. A token is approximately four characters. 100 tokens correspond to roughly 20 words.

Specify a lower value for shorter responses and a higher value for longer responses.

Temperature

The temperature is used for sampling during response generation, which occurs when topP and topK are applied. Temperature controls the degree of randomness in token selection. Lower temperatures are good for prompts that require a more deterministic and less open-ended or creative response, while higher temperatures can lead to more diverse or creative results. A temperature of 0 is deterministic, meaning that the highest probability response is always selected.

For most use cases, try starting with a temperature of 0.2. If the model returns a response that's too generic, too short, or the model gives a fallback response, try increasing the temperature.

Top-K

Top-K changes how the model selects tokens for output. A top-K of 1 means the next selected token is the most probable among all tokens in the model's vocabulary (also called greedy decoding), while a top-K of 3 means that the next token is selected from among the three most probable tokens by using temperature.

For each token selection step, the top-K tokens with the highest probabilities are sampled. Then tokens are further filtered based on top-P with the final token selected using temperature sampling.

Specify a lower value for less random responses and a higher value for more random responses. The default top-K is 40.

Top-P

Top-P changes how the model selects tokens for output. Tokens are selected from the most (see top-K) to least probable until the sum of their probabilities equals the top-P value. For example, if tokens A, B, and C have a probability of 0.3, 0.2, and 0.1 and the top-P value is 0.5, then the model will select either A or B as the next token by using temperature and excludes C as a candidate.

Specify a lower value for less random responses and a higher value for more random responses. The default top-P is 0.95.

Configure model parameters for Gemini models

Parameters for Imagen models

Learn about parameters available for use with Imagen models, including how to configure them.

The configuration is maintained for the lifetime of the initialized Vertex AI service and model instance. To update model configuration, the model instance must be re-initialized.

Description of each parameter

You can find a comprehensive list of parameters and their values in the Google Cloud documentation, but here is a high-level overview of the available parameters and their default values, as applicable.

Parameter Description Default value
Negative prompt
negativePrompt
A description of what you want to omit in generated images

This parameter is not yet supported by imagen-3.0-generate-002.

---
Number of results
numberOfImages
The number of generated images returned for each request default is one image for Imagen 3 models
Aspect ratio
aspectRatio
The ratio of width to height of generated images default is square 1:1
Image format
imageFormat
The output options, like the image format (MIME type) and level of compression of generated images default MIME type is PNG
default compression is 75 (if MIME type is set to JPEG)
Watermark
addWatermark
Whether to add a non-visible digital watermark (called a SynthID) to generated images default is true for Imagen 3 models
Person generation
personGeneration
Whether to allow generation of people by the model default depends on the model

Configure model parameters for Imagen models

Other options to control content generation

  • Learn more about prompt design so that you can influence the model to generate output specific to your needs.
  • Use safety settings to adjust the likelihood of getting responses that may be considered harmful, including hate speech and sexually explicit content.
  • Set system instructions to steer the behavior of the model. This feature is like a "preamble" that you add before the model gets exposed to any further instructions from the end user.
  • Pass a response schema along with the prompt to specify a specific output schema. This feature is most commonly used when generating JSON output, but it can also be used for classification tasks (like when you want the model to use specific labels or tags).