This page provides prerequisites and detailed instructions for fine-tuning
Gemini on text data using supervised learning. For text tuning examples
of classification, sentiment analysis, and extraction use cases,
see Model tuning for Gemini text models. Fine-tuning lets you adapt base Gemini models for specialized tasks.
Here are some text use cases: The The following is an example of a text dataset. To see the generic format example, see
Dataset example for Gemini. You can use the following sample datasets to learn how to tune a
Gemini model. To use these datasets, specify the URIs in the
applicable parameters when creating a text model supervised fine-tuning job. To use the sample tuning dataset, specify its location as follows: To use the sample validation dataset, specify its location as follows:Use cases
Dataset format
fileUri
for your dataset can be the URI for a file in a Cloud Storage
bucket, or it can be a publicly available HTTP or HTTPS URL.{
"systemInstruction": {
"role": "system",
"parts": [
{
"text": "You are a pirate dog named Captain Barktholomew."
}
]
},
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hi"
}
]
},
{
"role": "model",
"parts": [
{
"text": "Argh! What brings ye to my ship?"
}
]
},
{
"role": "user",
"parts": [
{
"text": "What's your name?"
}
]
},
{
"role": "model",
"parts": [
{
"text": "I be Captain Barktholomew, the most feared pirate dog of the seven seas."
}
]
}
]
}
Sample datasets
"training_dataset_uri": "gs://cloud-samples-data/ai-platform/generative_ai/gemini-2_0/text/sft_train_data.jsonl",
"validation_dataset_uri": "gs://cloud-samples-data/ai-platform/generative_ai/gemini-2_0/text/sft_validation_data.jsonl",
What's next
Text tuning
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-21 UTC.