Checkpoints
Enable the Vertex AI API
/ 20
Create prompts with text
/ 40
Create conversations with chat prompt
/ 40
Get Started with Generative AI Studio
GSP1154
Overview
Vertex AI is an end-to-end machine learning platform that helps you build, deploy, and scale machine learning models faster and easier. It provides a unified experience for managing all aspects of the machine learning lifecycle, from data preparation to model deployment.
Vertex AI Generative AI Studio is a cloud-based platform that allows users to create and experiment with generative AI models. The platform provides a variety of tools and resources that make it easy to get started with generative AI, even if you don't have a background in machine learning.
In this lab, you use Generative AI Studio with Vertex AI to create prompts and conversations on Google Cloud console, without using the API or Python SDKs.
Objectives
In this lab, you learn how to perform the following tasks:
- Create prompts with free-form and structured mode.
- Create conversations.
- Explore the prompt gallery.
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).
- Time to complete the lab---remember, once you start, you cannot pause a lab.
How to start your lab and sign in to the Google Cloud console
-
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
-
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. -
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.
-
Click Next.
-
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.
-
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. -
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.
Enable the Vertex AI API
-
In the Google Cloud Console, enter Vertex AI API in the top search bar.
-
Click on the result for Vertex AI API under Marketplace & APIs.
-
Click Enable.
Click Check my progress to verify the objectives.
Task 1. Create prompts
- In the Google Cloud Console, in the Navigation menu (
), navigate to Artificial Intelligence > Vertex AI.
- In the Vertex AI menu, under Generative AI Studio , click Language.
Create prompt
Create Prompt lets you designs prompts for tasks relevant to your business use case including code generation.
Click on the TEXT PROMPT button as shown in the image below. Please note the UI may change slightly when you are practicing with this lab.
Upon clicking, you will be redirected to the following page. You can hover or click on ? buttons on the right side of the page to learn more about each field and parameter such as Temperature and Token limit. Also, the following image has been annotated to provide a quick overview of the interface.
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.
There is no best way to design the prompts yet. Generally, there are 3 methods that you can use to shape the model's response in a way that you desired.
- Zero-shot prompting - This is a method where the LLM is given no additional data on the specific task that it is being asked to perform. Instead, it is only given a prompt that describes the task. 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.
You may also notice the FREE-FORM and STRUCTURED tabs in the image above. Those are the two modes that you can use when designing your prompt.
- FREE-FORM - This mode provides a free and easy approach to design your prompt. It is suitable for small and experimental prompts with no additional examples. You will be using this to explore zero-shot prompting.
- STRUCTURED - This mode provides an easy-to-use template approach to prompt design. Context and multiple examples can be added to the prompt in this mode. This is especially useful for one-shot and few-shot prompting methods which you will be exploring later.
FREE-FORM mode
You will try zero-shot prompting in FREE-FORM mode.
- Copy the following over to the prompt input field.
- Click on the SUBMIT button on the right side of the page.
The model will respond to a comprehensive definition of the term prompt gallery.
Here are some exploratory exercises to explore.
- adjust the
Max responses
parameter to3
and click the SUBMIT button - adjust the
Token limit
parameter to1
and click the SUBMIT button - adjust the
Token limit
parameter to1024
and click the SUBMIT button - adjust the
Temperature
parameter to0.5
and click the SUBMIT button - adjust the
Temperature
parameter to1.0
and click the SUBMIT button
Inspect if how the responses change as to change the parameters?
STRUCTURED mode
With STRUCTURED mode, you can design prompts in more organized ways. You can also provide Context and Examples in their respective input fields. This is a good opportunity to learn one-shot and few-shot prompting.
In this section, you will ask the model to complete a sentence.
- Return to the Text Prompt window.
- Click on the STRUCTURED tab if you have not.
- Remove any text from the Context
- Under Test field, copy the following in INPUT field.
- Click on the SUBMIT button on the right side of the page.
You would see similar results as shown in the image below.
Instead of completing the sentence, the model gave a full sentence as a response which is not what we wanted. You can try to influence the model's response with one-shot prompting. This time around you will add an example for the model to base its output from.
Under Examples field,
- Copy the following to the INPUT field.
- Copy the following to the OUTPUT field.
- Click on the SUBMIT button on the right side of the page.
Now the model will respond to complete the sentence instead. The response should be something like this.
You have successfully influenced the way the model produces response.
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.
- Return to the Text Prompt window.
- Under Examples field, delete the previous text for INPUT and OUTPUT for green grass.
- Under Test field, copy the following prompt over to the INPUT field.
- Click on the SUBMIT button on the right side of the page.
As you can see, the model did not have enough information to know whether you were asking it to do sentiment analysis. This can be improved by providing the model with a few examples of what you are looking for.
Try adding these examples as shown in the image below:
INPUT | OUTPUT |
---|---|
A well-made and entertaining film | positive |
I fell asleep after 10 minutes | negative |
The movie was ok | neutral |
and click on the SUBMIT button on the right side of the page.
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.
You can also save the newly designed prompt. To save the prompt, click on SAVE button and name it anyway you like, such as sentiment analysis test. Click SAVE.
(If you encounter an error while saving, please click Retry )
The saved prompt will appear at the MY PROMPTS tab.
Click Check my progress to verify the objectives.
Task 2. Create conversations
Create Chat Prompt lets you have a freeform chat with the model, which tracks what was previously said and responds based on context.
- Return to the Language page.
- Click on the TEXT CHAT button to create a new chat prompt.
You will see the new chat prompt page.
For this section, you will add context to the chat and let the model respond based on the context provided.
Add these contexts to the Context field.
- Copy these context to Context field.
- Copy the following text to the chatbox under Responses.
- Press Enter key or click Send message (right arrow-head button)
The model would consider the provided additional context and answer the questions within the constraints.
Save the newly designed prompt. To save the prompt, click on SAVE button and name it anyway you like. Click SAVE
Click Check my progress to verify the objectives.
Task 3. Explore prompt gallery
Prompt Gallery lets you explore how generative AI models can work for a variety of use cases.
In the Generative AI Studio menu, click on Language to find Prompt Gallery on the Get Started page.
Pick any two use cases from Summarization, Classification, Extraction, Writing, and Ideation, and explore them at your own pace.
Congratulations!
You learned how to create and test a prompt, create a conversation, and explore the prompt gallery. You have taken the first step to start your journey using Generative AI Studio and other Generative AI development tools!
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 31, 2023
Lab Last Tested October 31, 2023
Copyright 2023 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.