arrow_back

Get Started with Vertex AI Studio

Sign in Join
Test and share your knowledge with our community!
done
Get access to over 700 hands-on labs, skill badges, and courses

Get Started with Vertex AI Studio

Lab 1 hour universal_currency_alt 1 Credit show_chart Introductory
info This lab may incorporate AI tools to support your learning.
Test and share your knowledge with our community!
done
Get access to over 700 hands-on labs, skill badges, and courses

GSP1154

Google Cloud self-paced labs logo

Overview

Vertex AI is a comprehensive machine learning development platform that provides both predictive and generative AI capabilities. It allows you to train, evaluate, and deploy predictive machine learning models for forecasting purposes. Additionally, you can utilize the platform to discover, tune, and serve generative AI models to produce content.

Vertex AI Studio lets you quickly test and customize generative AI models so you can leverage their capabilities in your applications. It provides a variety of tools and resources including both UI (user interface) and coding examples that make it easy to start with generative AI, even if you don't have a background in machine learning.

This lab guides you through Vertex AI Studio, where you'll unlock the potential of cutting-edge generative AI models. You'll explore Gemini and use it to analyze images, design prompts, and generate conversations directly on the Google Cloud console. No need for API or Python SDKs - it's all accessible through the intuitive user interface.

Objectives

In this lab, you will learn how to:

  • Analyze images with Gemini
  • Explore Vertex AI Studio Freeform mode
  • Design text prompts for zero-shot, one-shot, and few-shot prompting
  • Generate conversations with chat prompts

Setup and requirements

Before you click the Start Lab button

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 will be made available to you.

This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab---remember, once you start, you cannot pause a lab.
Note: If you already have your own personal Google Cloud account or project, do not use it for this lab to avoid extra charges to your account.

How to start your lab and sign in to the Google Cloud console

  1. Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:

    • The Open Google Cloud console button
    • Time remaining
    • The temporary credentials that you must use for this lab
    • Other information, if needed, to step through this lab
  2. 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.

    Note: If you see the Choose an account dialog, click Use Another Account.
  3. If necessary, copy the Username below and paste it into the Sign in dialog.

    {{{user_0.username | "Username"}}}

    You can also find the Username in the Lab Details panel.

  4. Click Next.

  5. Copy the Password below and paste it into the Welcome dialog.

    {{{user_0.password | "Password"}}}

    You can also find the Password in the Lab Details panel.

  6. Click Next.

    Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials. Note: Using your own Google Cloud account for this lab may incur extra charges.
  7. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Google Cloud console opens in this tab.

Note: To view a menu with a list of Google Cloud products and services, click the Navigation menu at the top-left. Navigation menu icon

Task 1. Analyze images with Gemini in Freeform mode

In this section, you will use Gemini to analyze an image and extract information from it. In Freeform mode, you can design prompts for various tasks such as classification, extraction, and generation. There is no conversation history in Freeform mode, so every prompt is a brand-new request to the model.

Enable the Vertex AI API

  1. In the Google Cloud Console, enter Vertex AI API in the top search bar.

  2. Click on the result for Vertex AI API under Marketplace & APIs.

  3. Click Enable.

Enable Vertex AI API

Enable the Vertex AI API.

Analyze images with Gemini

  1. In the Google Cloud console, from the Navigation menu (Navigation menu), select Vertex AI > Vertex AI Studio > Overview.

Vertex AI Studio Overview page

  1. Under Generate with Gemini, click Open Freeform.

The UI contains three main sections:

  • Prompt (located in the center): Here, you can create a prompt that utilizes multimodal capabilities.
  • Configuration (located on the right): This section allows you to select models, configure parameters, and obtain the corresponding code.
  • Response (located at the bottom): This section displays the results of your prompt. Vertex AI Studio
  1. On the top left, click Untitled Prompt and rename your prompt as Image Analysis.

  2. In the Configuration section on the top right, click on the Model dropdown then select the gemini-1.5-pro model.

  3. Download the sample image. Right-click the timetable image and then save it to your desktop.

timetable

  1. On the top right of the Prompt section, click Insert media > Upload. Upload the timetable image you downloaded. The media can be in the form of an image, video, text, or audio file.

Insert media into Vertex AI Studio

  1. The image will be displayed inside of the Prompt section. Copy the following text and paste it under the image and click on the Submit button on the bottom right of the Prompt section.
Title the image.

Or be more specific:

Title the image in 3 words.

Does the title meet your expectations? Try to modify the prompt to see if you get different results.

  1. Describe the image. Replace the previous prompt with the following and click the Submit button.
Describe the image in detail.
  1. Tune the parameter. In the Configuration section, adjust the temperature by scrolling from left (0) to right (2). Resubmit the prompt to observe any changes in the outcome compared to the previous result.
Note: Temperature controls the degree of randomness in token selection. Lower temperatures are good for prompts that expect a true or correct response, while higher temperatures can lead to more diverse, unexpected, or potentially biased results. With a temperature of 0 the highest probability token is always selected.
  1. Extract the text from the image. Replace the previous prompt with the following:
Read the text in the image.

Further on, if you want to format the output to a list, replace the previous prompt with the following:

Parse the time and city in this image into a list with two columns: time and city.

Your turn - try out some different prompts! How do these results differ from before?

  1. Analyze the information on the image. Replace the previous prompt with the following:
Calculate the percentage of the flights to different continents.

Does the result meet your expectations? You are highly encouraged to try different prompts for various tasks. You are also encouraged to experiment with different temperature settings to observe the changes in the result.

  1. Once you finish the prompt design, save the prompt by clicking Save on the top right of the Configuration section. For the region, select from the dropdown and then confirm by clicking Save.

  2. To find your saved prompts, on the left-hand navigation menu, navigate to Prompt Management.

Note: After selecting Save, give the prompts a few seconds to properly save and then proceed further with the lab. Click "Try again" if prompted "failed to update history."

Click Check my progress to verify the objectives.

Extract the content of the image.

Task 2. Explore multimodal capabilities

In addition to images, text, and audio, Gemini is capable of accepting videos as inputs and generating text as an output.

  1. Navigate to Cloud Storage > Buckets and copy the name of your Cloud Storage bucket and save it to use in the further step.

  2. Click Activate Cloud Shell Activate Cloud Shell icon at the top of the Google Cloud console.

  3. In your Cloud Shell terminal, run the command below to copy the sample video gs://spls/gsp154/video/train.mp4 (preview) to your Cloud Storage bucket. Replace <Your-Cloud-Storage-Bucket> with the bucket name you copied earlier.

gcloud storage cp gs://spls/gsp154/video/train.mp4 gs://<Your-Cloud-Storage-Bucket> Note: Make sure to replace the <Your-Cloud-Storage-Bucket> with your bucket name.
  1. From the Navigation menu (Navigation menu), select Vertex AI > Vertex AI Studio > Overview.

  2. Under Generate with Gemini, click Open Freeform.

  3. Click Inset Media > Import from Cloud Storage.

  4. Click on your bucket name and then click on the sample video i.e., train.mp4 and click Select.

  5. Generate information about the video by inserting the following prompt and clicking the Submit button.

Title the video.

Freeform mode offers many capabilities such as writing stories from images, analyzing videos, and generating multimedia ads. Explore more freeform use cases by clicking Prompt gallery. Check out more information about design multimodal prompts.

Task 3. Design text prompts

In this section, you will explore designing text prompts in Vertex AI Studio. You will explore zero-shot, one-shot, and few-shot prompting.

Prompt design

You can feed your desired input text, e.g. a question, to the model. The model will then provide a response based on how you structured your prompt. The process of figuring out and designing the best input text (prompt) to get the desired response back from the model is called Prompt Design.

Prompt design methods

There are three main methods to design prompts:

  • Zero-shot prompting - This is a method where the LLM is given only a prompt that describes the task and no additional data. For example, if you want the LLM to answer a question, you just prompt "what is prompt design?".
  • One-shot prompting - This is a method where the LLM is given a single example of the task that it is being asked to perform. For example, if you want the LLM to write a poem, you might give it a single example poem.
  • Few-shot prompting - This is a method where the LLM is given a small number of examples of the task that it is being asked to perform. For example, if you want the LLM to write a news article, you might give it a few news articles to read.

Parameters

Temperature and Token limit are two important parameters that you can adjust to influence the model's response.

  • Temperature controls the randomness in token selection. A lower temperature is good when you expect a true or correct response. A temperature of 0 means the highest probability token is always selected. A higher temperature can lead to diverse, unexpected, or potentially biased results. The gemini-1.5-pro model has a temperature range of 0 - 2 and a default of 1.
  • Output token limit determines the maximum amount of text output from one prompt. A token is approximately four characters.

Zero-shot prompting

Try zero-shot prompting in Free-form mode.

  1. Navigate back to the Vertex AI Studio > Overview page and click Open Freeform.

  2. On the top right under Model, select the gemini-1.5-pro model.

Note: The model name and version may change with the release of new models.
  1. Copy the following over to the prompt input field:
What is a prompt gallery?
  1. Click on the Submit button.

The model will respond to a comprehensive definition of the term prompt gallery.

Here are some exploratory exercises to explore.

  • Adjust the Output Token limit parameter to 1024 and click the SUBMIT button.
  • Adjust the Temperature parameter to 0.5 and click the SUBMIT button.
  • Adjust the Temperature parameter to 2.0 and click the SUBMIT button.

Inspect how the responses change as to change the parameters.

One-shot prompting

You can design prompts in more organized ways. You can provide Context and Examples in their respective input fields. One-shot prompting is a method where the model is given a single example of the task that it is being asked to perform. In this section, you will ask the model to complete a sentence.

  1. Start by removing any text from the Prompt box.

  2. Inside of the Prompt box, click Add examples. This will open a new window where you can add examples for the prompt.

add examples

  1. Add this to the INPUT field:
The color of the grass is
  1. Add this to the OUTPUT field:
The color of the grass is green
  1. Click on the Add examples button.

  2. In the Test field, copy the following in the Input field.

The color of the sky is
  1. Click on the Submit button. You should receive a response from the model similar to the following:
The color of the sky is blue

Instead of completing the sentence, the model gave a full sentence as a response since you provided an example for the model to base its output from. To change the response to simply complete the sentence, you can adjust the example provided in the OUTPUT field.

  1. Click the Examples button in the Prompt box and change the OUTPUT field to:
Green
  1. Click on the Add examples button.

  2. In the Test field, copy the following in the Input field.

The color of the sky is
  1. Click on the Submit button. You should receive a response from the model similar to the following:
blue

You can see that the model now completes the sentence based on the example you provided. You have successfully influenced the way the model produces response.

Few-shot prompting

For the next practice, you will use the model to perform sentiment analysis on a sentence, such as determining whether a movie review is positive or negative using few-shot prompting.

  1. In the Prompt field, delete your examples from the previous section. To delete your examples, hover over the Examples and click the X (Remove File) button.

remove examples

  1. Click the Add examples button to add more examples.

  2. Add the following examples:

INPUT OUTPUT
A well-made and entertaining film positive
I fell asleep after 10 minutes negative
The movie was ok neutral
  1. Once you have added the examples, click on the Add examples button.

structured

  1. In the Test field, copy the following in the Input field.
It was a time well spent!
  1. Click on the Submit button.

test

The model now provides a sentiment for the input text. For the text It was a time well spent!, the sentiment is labeled as positive.

  1. Once you finish the prompt design, save the prompt by clicking Save on the top right of the Configuration section. Name the prompt as Sentiment Analysis. For the region, select from the dropdown and then confirm by clicking Save.

Click Check my progress to verify the objectives.

Create prompts with text

Task 4. Generate conversations

Chat mode is a conversational mode that allows you to have a freeform chat with the model. The model uses the conversation history as context for future responses. In this section, you will create a chat prompt and have a conversation with the model.

  1. From the left menu, navigate to Chat to create a new chat prompt.

  2. On the top right under Model, select the gemini-1.5-flash model.

Note: The model name and version may change with the release of new models.

For this section, you will add context to the chat and let the model respond based on the context provided.

  1. Add the following context to the System instructions field by clicking the Edit button.
Your name is Roy. You are a support technician of an IT department. You only respond with "Have you tried turning it off and on again?" to any queries.
  1. Click Apply.

  2. Insert the following prompt:

My computer is so slow! What should I do?
  1. Click the Submit button.

The model should respond with the following:

Have you tried turning it off and on again?
  1. Next, edit the context of the existing System instructions field by clicking the Edit button.

  2. Update the context with the following:

Your name is Roy. You are a support technician of an IT department. You are here to support the users with their queries.
  1. Insert the following prompt:
My computer is so slow! What should I do?
  1. Click the Submit button.

The model should now be more helpful in its response to the user query.

Feel free to experiment with different prompts and context to see how the model responds. You can also add more context to the chat prompt to see how the model responds based on the context provided.

  1. Once you finish the prompt design, save the prompt by clicking Save on the top right of the Configuration section. Name the prompt as Support Technician Helper. For the region, select from the dropdown and then confirm by clicking Save.

Click Check my progress to verify the objectives.

Create conversations with chat prompt

Congratulations!

You learned how to analyze an image with freeform, explore freeform capabilities, create and test a prompt, and generate a conversation. You have taken the first step to start your journey using Vertex AI Studio and Gemini Freeform!

Google Cloud training and certification

...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 October 8, 2024

Lab Last Tested October 8, 2024

Copyright 2024 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