
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Install packages, and configure the notebook.
/ 20
Prepare the dataset
/ 20
Compare baseline model performance to ground truth
/ 10
Evaluate the baseline model with the validation dataset
/ 20
Create the fine-tuned model
/ 20
Evaluate the fine-tuned model
/ 10
Gemini is a family of generative AI models developed by Google DeepMind that is designed for multimodal use cases. The Gemini API gives you access to the various Gemini models, such as Gemini Pro, Flash and Flash Lite.
With this lab you learn how to fine-tune the Gemini Flash generative model using the Vertex AI Supervised Fine-Tuning feature. Supervised Fine-Tuning allows you to use your own training data to further refine the base model's capabilities towards your specific tasks.
Supervised Fine-Tuning uses labeled examples (in this case images) to tune the base Gemini model. Each example demonstrates the output you want from your text model during inference.
Before you begin tuning, ensure your training data is of high quality, well-labeled, and directly relevant to the target task. This is crucial as low-quality data can adversely affect the performance and introduce bias in the fine-tuned model.
When you start the lab, the environment will contain the resources that are shown in the following diagram.
By the end of the lab, you will have used the architecture to perform several tasks.
The following table provides a detailed explanation of each task in relation to the lab architecture.
Numbered Task | Detail |
---|---|
1. | Open the notebook in Vertex AI Workbench and choose kernel. |
2. |
Install packages, and configure the notebook for your project: You will use the Google Gen AI SDK to work with Gemini through the Developer API and Vertex AI. This will require you to install python libraries and reference them throughout the lab. You also need to configure the notebook to have access to resources in your project, like the Cloud Storage bucket provided to you at lab launch. |
3. |
Prepare the dataset: In this task you download the dataset files including the images, and prepare them for use with your notebook. |
4. |
Compare baseline model performance to ground truth: You will compare the baseline Gemini Flash model against the ground truth of a single image in the dataset. |
5. |
Evaluate the baseline model with the validation dataset: You will use val.jsonl with your prompt and the baseline Gemini Flash model to evaluate its results. Note: you will use various evaluation metrics like rougeL_precision, rougeL_recall, and rougeL_fmeasure to evaluate the tuned model's performance. |
6. |
Create the fine-tuned model: You use your training data train.jsonl along with the baseline Gemini Flash model to create a fine-tuned model for your specific image captioning use case. |
7. |
Evaluate the fine-tuned model: You use evaluation metrics to evaluate the fine-tuned model against the validation dataset val.jsonl and the performance of the baseline Gemini Flash model. Evaluation will occur with evaluation metrics like rougeL. |
Before starting this lab, you should be familiar with:
In this lab, you will:
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
In the Google Cloud console, on the Navigation menu (), click Vertex AI > Workbench.
Find the
The JupyterLab interface for your Workbench instance opens in a new browser tab.
1. Close the browser tab for JupyterLab, and return to the Workbench home page.
2. Select the checkbox next to the instance name, and click Reset.
3. After the Open JupyterLab button is enabled again, wait one minute, and then click Open JupyterLab.
Open the
In the Select Kernel dialog, choose Python 3 from the list of available kernels.
In this task you install the required Python packages, restart the kernel runtime, configure your notebook to use your project and region, and import libraries.
Complete the steps in Task 2, Install packages, and configure the notebook section of the notebook.
For Project ID, use
Click Check my progress to verify the objective.
In this task, you download the dataset files including the images, and prepare them for use with your notebook.
Click Check my progress to verify the objective.
In this task, you will compare the baseline Gemini Flash model against the ground truth of a single image in the dataset.
Click Check my progress to verify the objective.
In this task, you will use val.jsonl with your prompt and the baseline Gemini Flash model to evaluate its results.
Click Check my progress to verify the objective.
In this task, you use your training data train.jsonl along with the baseline Gemini Flash model to create a fine-tuned model for your specific image captioning use case.
Click Check my progress to verify the objective.
In this task, you use evaluation metrics to evaluate the fine-tuned model against the validation dataset val.jsonl and the performance of the baseline Gemini Flash model. Evaluation will occur with evaluation metrics like rougeL.
Click Check my progress to verify the objective.
In this lab, you learned how to use the supervised fine-tuning capability of Vertex AI to fine-tune Gemini using custom data to enhance its image captioning ability.
Check out the following resources to learn more about Gemini:
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated July 12, 2025
Lab Last Tested July 12, 2025
Copyright 2025 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one