Intermediate

Model Tuning in Google AI Studio

Create custom fine-tuned Gemini models using your own training data. Learn the complete workflow from data preparation to deployment.

What is Model Tuning?

Model tuning (also called fine-tuning) is the process of training an existing AI model on your own data to specialize it for your specific tasks. Instead of building a model from scratch, you take a pre-trained Gemini model and teach it to perform better at your particular use case.

Common reasons to tune a model:

  • Improve accuracy for domain-specific tasks (medical, legal, technical)
  • Teach the model your organization's writing style or terminology
  • Create consistent outputs for classification or extraction tasks
  • Reduce the need for long, complex prompts
💡
Good to know: Tuning doesn't create a new model from scratch. It adjusts the weights of an existing Gemini model based on your examples, so the model retains its general capabilities while becoming better at your specific tasks.

Creating a Tuned Model

Follow these steps in Google AI Studio:

  1. Click "New tuned model" in the left navigation
  2. Give your tuned model a descriptive name
  3. Select the base model (typically Gemini Pro or Flash)
  4. Upload your training data
  5. Configure training parameters
  6. Start training and monitor progress

Preparing Training Data

Your training data should be formatted as input-output pairs. Google AI Studio accepts two formats:

CSV Format

input,output
"What's your return policy?","We offer 30-day returns for all unused items in original packaging."
"How long does shipping take?","Standard shipping takes 5-7 business days. Express shipping takes 2-3 business days."
"Do you ship internationally?","Yes, we ship to over 50 countries. International shipping takes 10-15 business days."

JSON Format

[
  {
    "text_input": "What's your return policy?",
    "output": "We offer 30-day returns for all unused items in original packaging."
  },
  {
    "text_input": "How long does shipping take?",
    "output": "Standard shipping takes 5-7 business days. Express shipping takes 2-3 business days."
  }
]

Training Configuration

When configuring your tuning job, you'll set these parameters:

ParameterDescriptionRecommendation
EpochsNumber of times the model processes the entire training dataset5-20 for most datasets
Learning rateHow much the model adjusts with each training stepUse the default unless you have specific needs
Batch sizeNumber of examples processed together4-16 depending on dataset size

Training Process

Once you start training:

  1. The training job is queued and begins processing
  2. You can monitor the loss curve in real-time (lower loss = better learning)
  3. Training typically takes 5-30 minutes depending on data size and epochs
  4. You'll receive a notification when training completes

Evaluating Your Tuned Model

After training, evaluate your model's quality:

  • Test in AI Studio: Use the tuned model directly in a prompt to compare results
  • Check the loss curve: A steadily decreasing loss indicates successful training
  • Compare outputs: Run the same prompts on both the base and tuned model
  • Use a holdout set: Test with examples that weren't in the training data
Watch out: If the loss curve flattens too early or starts increasing, your model may be overfitting. Try using more diverse training examples, reducing epochs, or lowering the learning rate.

Using Tuned Models via API

Once tuned, your model is available through the Gemini API just like standard models:

import google.generativeai as genai

genai.configure(api_key="YOUR_API_KEY")

# Use your tuned model
model = genai.GenerativeModel("tunedModels/your-model-name")
response = model.generate_content("What's your return policy?")
print(response.text)

Fine-Tuning Best Practices

📊

Quality Over Quantity

50 high-quality examples often outperform 500 sloppy ones. Ensure your training data is accurate, consistent, and representative of real-world inputs.

🔄

Diverse Examples

Cover edge cases and variations in your training data. Include different phrasings, lengths, and complexities to build a robust model.

🔍

Iterative Refinement

Start with a small dataset, evaluate, then add more examples targeting weak areas. Multiple rounds of tuning with improved data yield the best results.

Cost Considerations

Model tuning in Google AI Studio has a generous free tier. Be aware of:

  • Training jobs consume compute resources (free tier has limits)
  • Tuned models may have different rate limits than base models
  • Storage of tuned models counts toward your quota
  • API calls to tuned models are priced similarly to the base model

💡 Try It: Create a Tuned Model

Prepare a CSV file with at least 20 input-output pairs for a task relevant to your work (e.g., email classification, FAQ answering, content summarization). Upload it to AI Studio and create a tuned model. Compare its performance against the base model.

Model tuning is most impactful when you have a well-defined task with clear input-output expectations!

Ready to Go Deeper?

Live instructor-led courses from our partners. Affiliate disclosure.