Tuning & Customization
Tuning & Customization on Google Cloud covers workflows that adapt foundation models, prompts, embeddings, search ranking, and translation models to task-specific data. In these notebooks, customization is driven by curated datasets, Cloud Storage artifacts, Vertex AI or Agent Platform jobs, and evaluation before and after changes.
Synthesized across 21 notebooks. See the source pages under Notebooks below for line-level grounding.
This area spans prompt optimization, supervised fine-tuning, preference optimization, embedding tuning, Vertex AI Search tuning, open-model tuning, and Cloud Translation custom NMT training. The common pattern is to prepare task-specific data in the required format, store it in Cloud Storage, run a managed tuning or optimization job, and evaluate the result against a baseline.
Most Gemini workflows use JSONL training and validation files, separate evaluation or test splits, and asynchronous Vertex AI tuning jobs that may automatically deploy tuned models to endpoints. Prompt and migration workflows emphasize evaluation datasets, rubric or custom metrics, and re-evaluation after prompt or model changes.
Multimodal and open-model workflows add extra operational requirements: GCS file references for images, attached read configurations for Agent Platform multimodal datasets, GPU-specific notebook runtimes or custom containers, Hugging Face tokens for gated models, and explicit cleanup to avoid endpoint, storage, and experiment charges.
Canonical workflow
- Enable the required APIs, configure project, region, billing, authentication, service accounts, and Cloud Storage buckets.
- Prepare task-specific data in the required format, such as Gemini JSONL, preference JSONL, embedding corpus/query/label files, TSV mappings, CSV or JSONL validation samples, or DOCX-derived translation TSV rows.
- Split data into train, validation, and test or evaluation sets before tuning, and keep serving or test examples formatted like training data.
- Establish a baseline with the base model, existing prompt, search app, embedding model, or translation dataset before customization.
- Validate data schemas, sample counts, multimodal turn order, labels, targets, GCS permissions, and job configuration before launching tuning or optimization.
- Run the tuning, prompt optimization, evaluation, batch prediction, or custom container job, then poll asynchronous jobs until they reach a terminal state.
- Evaluate the tuned or optimized result with task-appropriate metrics, row-level outputs, generated responses, or before-and-after comparisons against the baseline.
- Inspect artifacts, experiment runs, endpoints, and reports, then clean up endpoints, buckets, jobs, experiments, data stores, engines, and local files when no longer needed.
Best practices
See Tuning & Customization - Best Practices for the full distilled guide.
- Use high-quality, well-labeled, task-relevant data; low-quality data can hurt tuned model performance and introduce bias.
- Create separate training, validation, and test or evaluation splits before tuning so reported quality is not measured on examples seen during training.
- Store tuning datasets, validation data, evaluation outputs, OCR results, and model artifacts in Cloud Storage using clear or timestamped paths.
- Validate input formats before launch: Gemini JSONL schemas, preference pairs, multimodal read configurations, image fileData references, embedding corpus/query/label files, TSV mappings, and prompt optimizer validation samples.
- Establish a baseline before customization, then compare the base model, prompt, search app, or embedding model with the tuned or optimized result on the same task.
- Choose metrics that match the task: ROUGE for summarization or captions, EM/F1 for Q&A, NDCG for embeddings, rubric metrics for model migration, custom metrics for task-specific SFT, and human plus automated ratings for prompts.
Key models & APIs
- gemini-2.0-flash, gemini-2.0-flash-001, gemini-2.0-flash-lite-001, gemini-2.5-flash, gemini-2.5-flash-001, gemini-2.5-flash-lite, gemini-2.5-pro, gemini-1.5-flash-002, gemini-1.5-pro-002, text-embedding-005, gpt-4o, meta/llama3_1@llama-3.1-8b, meta-math/MetaMath-7B-V1.0, unsloth/gpt-oss-20b, google/gemma-2b, Vertex AI API, Agent Platform API, Vertex AI Gen AI Evaluation SDK and Service, Google Gen AI SDK, Vertex AI Prompt Optimizer, Vertex AI Experiments, Vertex AI tuningJobs REST v1beta1, Vertex AI Search and Discovery Engine, Document AI API, Cloud Translation API custom NMT training, Cloud Storage and Cloud Storage API, BigQuery and BigFrames, Artifact Registry API, Hugging Face PyTorch training DLCs, TRL, Unsloth
Notebooks (21)
Embeddings & Vector Search (1)
- Get started with embeddings tuning on Agent Platform — Tunes text-embedding-005 for retrieval using synthetic Gemini queries and Document AI PDF chunks.
Gemini (14)
- Migrating Foundation Models: A Practical Guide with Gen AI Evaluation Serivce — Compares model migration candidates with Vertex AI Gen AI Evaluation and prompt optimization workflows.
- Intro to Agent Platform Multimodal Datasets — Builds Agent Platform multimodal datasets for Gemini tuning validation, resource estimates, tuning, and batch prediction.
- Vertex Prompt Optimizer Notebook UI (Preview) — Shows how to configure, run, and inspect Vertex AI Prompt Optimizer jobs from a notebook UI.
- Prepare High-Quality Preference Data for Gemini 2.5 — Prepares and filters Gemini preference data with Vertex AI Gen AI Evaluation SDK for DPO and SFT.
- Get Started with Gemini Preference Optimization — Tunes Gemini 2.5 Flash with human preference data using Vertex AI preference optimization.
- Supervised Fine-Tuning with integrated Gen AI Evaluation — Fine-tunes gemini-2.5-flash with automatic Gen AI Evaluation metrics at each checkpoint.
- Integrate Custom Metrics into Gemini Supervised Fine-Tuning — Adds a Python custom metric to Gemini SFT using Vertex AI REST tuning jobs and GCS outputs.
- Vertex AI SFT Gemini Migration Recipe — Migrates explicit SFT hyperparameters from gemini-1.5-flash-002 tuning jobs to gemini-2.5-flash.
- Supervised Fine Tuning with Gemini 2.5 Flash for Image Captioning — Fine-tunes Gemini 2.5 Flash on GCS image-caption pairs and evaluates ROUGE before and after tuning.
- Supervised Fine Tuning with Gemini 2.0 Flash for change detection using the Google Gen AI SDK — Fine-tunes Gemini 2.0 Flash on paired images for spot-the-difference change detection.
- Supervised Fine-tuning Gemini 2.5 Flash for Predictive Maintenance — Fine-tunes Gemini 2.5 Flash on simulated sensor data to classify equipment maintenance status.
- Supervised fine-tuning with Gemini 2.0 Flash for Q&A using the Google Gen AI SDK — Fine-tunes Gemini 2.0 Flash on SQuAD Q&A with Vertex AI supervised tuning and evaluates EM/F1 gains.
- Supervised Fine Tuning with Gemini 2.5 Flash for Article Summarization — Fine-tunes Gemini 2.5 Flash on WikiLingua article summaries and evaluates ROUGE before and after tuning.
- Supervised Fine-tuning Gemini 2.5 Flash for Visual Defect Detection — Fine-tunes Gemini 2.5 Flash on image-based manufacturing defect classification.
Open Models (3)
- MetaMath with Vertex AI Open Source Model Tuning — Fine-tunes a Llama 3.1 8B model on MetaMathQA using Vertex AI managed tuning.
- Fine-tuning GPT-OSS 20B with Unsloth on Vertex AI Colab Enterprise and Nvidia A100 40GB GPU — Fine-tunes GPT-OSS 20B with Unsloth LoRA on Vertex AI Colab Enterprise using an A100 GPU.
- Hugging Face DLCs: Fine-tuning Gemma with Transformer Reinforcement Learning (TRL) on Vertex AI — Fine-tunes google/gemma-2b with TRL SFT and LoRA in a Vertex AI custom container job.
Vertex AI Search (1)
- Search tuning in Vertex AI Search — Tunes Vertex AI Search with JSONL/TSV Q&A data and tests a search app over Cloud Storage PDFs.
Tools (1)
- Tutorial for Running Prompt Management and Evaluation — Runs prompt management, MathVista evaluation, and Vertex AI prompt optimization in a Streamlit app.
Translation (1)
- Generate training dataset for Cloud Translation API NMT (Neural Machine Translation) model training — Generates DOCX translation TSV data and starts Cloud Translation custom NMT training.
Related concepts
- Evaluation · Open & Partner Models · MLOps & Deployment · Prompt Engineering · Applied Use Cases · Vision · RAG & Grounding · Embeddings & Vector Search
Part of the Generative AI Google Brain · Tuning & Customization - Best Practices