Tune a model with Google AI Studio

When building an application with Gemini artificial intelligence (AI) models, you may want to provide stronger guidance for how the model responds to instructions or requests than what is possible with freeform prompts or structured prompts. Model tuning lets you change the behavior of a model more substantially and also requires significantly more training example data than what fits in a typical prompt. Another benefit of tuned models is they can be used with more than one prompt. For more information about model tuning, see the model tuning guide.

This guide describes how to create and use a tuned model with Google AI Studio.

Create tuning dataset

Tuning a model requires more examples, or training data, than standard prompting techniques. You can tune a model with as few as 20 examples. In general, you need between 100 and 500 examples to significantly change the behavior of the model. If you do not have a training dataset of this size or larger, try using structured prompts first, as this feature lets you guide the behavior of the model with as little as 3 or 4 training examples.

The training examples you provide in your tuning dataset guide the generative model in producing responses. At the minimum, each record in your dataset must have an input value, representing the prompt instruction, and an output value, representing the expected response from the generative model.

Here's an example of input and output values for this prompt. In this case, the Product name is the input, or prompt, for the model, and the Product copy is the expected output:

Product name (input) Product copy (output)
Old-school sneaker Let's lace up! These kicks bring an iconic look and a one of a kind color palette, while supporting you in style and function like no other shoe before.
Supersoft hoodie Stay cozy and stylish in our new unisex hoodie! Made from 100% cotton, this hoodie is soft and comfortable to wear all day long. The semi-brushed inside will keep you warm on even the coldest days.

A training dataset can have more than one input and more than one output, and you must have at least one input and one output for each record. You can create datasets using the structured prompts user interface in AI Studio, or import data from a Comma Separated Value (CSV) data file or Google Sheets spreadsheet.

Create a tuned model

After you create a tuning dataset, you can build a tuned version of a Gemini model in AI Studio by providing your dataset and setting some configuration parameters. Once you have provided the required input, the system creates the tuned model, and then you can use it with your prompts.

To create a tuned model:

  1. In the AI Studio web app, on the left side of the interface, select the Tuned model option.
  2. In the Select Data for tuning dialog, connect your tuning dataset by selecting a Structured prompt or click the Import button to load a data in a comma separated value (.CSV) format file or a Google Sheets spreadsheet.
  3. In the Tuned model name field, enter a name for your tuned model. This name appears as a selectable model once the tuning operation is complete.
  4. In the Description field, enter an optional description of the tuned model.
  5. In the Model field select the foundation model you want to use as the base for your tuned model.
  6. You can optionally set Advanced settings for creating the tuned model. For more information about these settings, see the Model tuning guide.
  7. Start the process to create the tuned model by selecting Tune.

The system might take a few minutes or longer to build the tuned version depending on the size or your dataset, number of Epochs specified, and current system load. You can check on the status of the tuning process by selecting My Library on the left side of the application and looking for the name of the tuned model.

Use the tuned model

After the model tuning build is complete, you can select the model for use with your prompts. You can use the tuned model with existing or new freeform or structured prompts, as long as those the prompts conform to the example structure of your tuned dataset.

To use a tuned model:

  1. In the AI Studio web app, open an existing prompt or start a new one.
  2. In the Run settings section, select the Model drop down, and select the name of the tuned model.
  3. Compose or update your prompt and select Run to use tuned model.

Tuning requires a significant amount of data to change the behavior of the generative model. If your prompts are not producing the behavior you want, evaluate your tuning dataset, your tuning parameters, and consider adding more examples.