Контрольні точки
Enable the Vertex AI API
/ 20
Extract the content of the image
/ 20
Extract the content of the video
/ 20
Create prompts with text
/ 40
Use Vertex AI Studio for Healthcare
GSP1252
Disclaimer: The information in this course is for educational purposes only, and does not serve as Google's approval for use of its generative AI service for any diagnostic or therapeutic purpose, or for direct patient care.
Overview
Vertex AI is a powerful machine learning platform designed to enhance healthcare applications with both predictive and generative AI capabilities. Vertex AI Studio serves as an intuitive interface, allowing healthcare practitioners and researchers to easily experiment with and customize generative AI models without extensive machine learning expertise. This user-friendly platform provides a variety of tools and resources, including UI-based interactions and code examples, making it simple to harness the power of generative AI for healthcare applications.
In this hands-on lab, you'll delve into Vertex AI Studio, where you'll explore the capabilities of cutting-edge generative AI models like Gemini multimodal. With Gemini, you'll experiment with prompt design techniques to summarize text, answer questions, and classify sentiments. All of this can be done directly within the Google Cloud console, without the need for complex APIs or Python SDKs, making it accessible to healthcare professionals with varying levels of technical expertise.
Objectives
In this lab, you will learn how to:
- Analyze images with Gemini multimodal.
- Explore multimodal capabilities.
- Design prompts with free-form and structured mode.
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. Analyze images with Gemini multimodal
- In the Google Cloud console, from the Navigation menu (), select Vertex AI > Vertex AI Studio > Overview.
You find four features: Multimodal, Language, Vision, and Speech.
- Under Multimodal powered by Gemini, click Try Gemini.
The UI contains three main sections:
- Prompt (located at the top): Here, you can create a task 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 task.
-
On the top left, click Untitled Prompt and rename your prompt as
Medical Image Analysis
. -
On the top right under Model, select the gemini-1.5-pro model.
-
Download the sample image. Right-click the chest x-ray image and then save it to your desktop.
- Click Insert media > Upload from computer on top right and upload the x-ray image. The media can be either images or videos.
- The image will be displayed inside of the Prompt section. Copy the following text and paste it under the image and click Submit.
Or be more specific:
Does the title meet your expectations? Try to modify the prompt to see if you get different results.
- Describe the image. Replace the previous prompt with the following and click Submit.
- Tune the parameter. 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.
- Extract information from the image. Replace the previous prompt with the following:
Further on, if you want to format the output to a list, replace the previous prompt with the following:
Your turn - try out some different prompts! How do these results differ from before?
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.
- 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.
To find your saved prompts, navigate to Multimodal > My prompts.
Click Check my progress to verify the objectives.
Task 2. Explore multimodal capabilities
In addition to images and text, Gemini multimodal is capable of accepting videos as inputs and generating text as an output. To obtain the video, you will click on a link to a lung animation video, save the video to your desktop and upload the video into Vertex AI Studio.
- Click this link to the lung animation video. The video should appear in your web browser. Right-click on the video to save the video to your computer.
-
Navigate back to the Vertex AI Studio > Overview page and click Try Gemini.
-
On the top right under Model, select the gemini-1.5-pro model.
-
Click Insert Media > Upload from computer. Select the lung animation video you downloaded and click Open.
-
Generate any information about the video by inserting your own prompt.
For example, to describe the video in detail, copy the following into the Prompt section and click Submit.
-
On the top left, click Untitled Prompt and rename your prompt as
Medical Video Analysis
. -
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.
Multimodal powered by Gemini offers many capabilities such as writing simple explanations of complex images, analyzing videos, and generating educational multimedia visual aids. Explore more multimodal use cases by clicking Multimodal > Sample Prompts. Check out more information about design multimodal prompts.
Click Check my progress to verify the objectives.
Task 3. Design prompts with free-form and structured mode
-
Navigate back to the Vertex AI Studio > Overview page.
-
Click Open for Language Powered by Gemini.
Create prompt
Create Prompt lets you design prompts for tasks relevant to your healthcare use case.
- Click on the Text Prompt button as shown in the image below. The UI may differ slightly from this screenshot.
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.
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 is no best way to design the prompts yet. There are 3 methods you can use to shape the model's response:
- 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.
Free-form and structured mode
You may also notice the FREE-FORM and STRUCTURED tabs. 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.
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.
Free-form mode
Try zero-shot prompting in Free-form mode.
- On the top right under Model, select the gemini-1.5-pro model.
- 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 with a list of common medical conditions.
Here are some exploratory exercises to explore.
- Adjust the
Output Token limit
parameter to1024
and click the SUBMIT button. - Adjust the
Temperature
parameter to0.5
and click the SUBMIT button. - Adjust the
Temperature
parameter to2.0
and click the SUBMIT button.
Inspect how the responses change with different parameters.
- 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 with a detailed explanation of the underlying mechanism of Type 1 diabetes.
- Next, 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 with a list of common treatments for a sprained ankle.
Structured mode
With Structured mode, you can design prompts in more organized ways. You can 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 design prompts for one-shot and few-shot prompting.
One-shot prompting
- Still on the Text Prompt page, click on the STRUCTURED tab. The prompt design page will change to a structured mode.
- Remove any text from the Context field. Add the following:
- Under Examples field, copy the following in the INPUT field.
- Add the following to the OUTPUT field:
- Under Test field, copy the following in the INPUT field.
- Click on the SUBMIT button on the right side of the page.
The model will respond with an explanation of diabetes simplified to a 6th grade reading level.
Few-shot prompting
This time around, add a few examples for the model to base its output from.
- In the Context field, update the text to:
Under Examples field, add the following examples, keeping your existing arthritis example from the previous section:
- Add this to the INPUT field:
- Add this to the OUTPUT field:
- Add this to the INPUT field:
- Add this to the OUTPUT field:
- Under the Test field, copy the following in the INPUT field.
- Click on the SUBMIT button on the right side of the page.
You have successfully influenced the way the model produces response. Your model now generates an explanation of cancer simplified to a 6th grade reading level, displayed in a table.
Text Summarization
For the next practice, you will use the model to summarize a paragraph into a single sentence.
- At the top of the page, click on the FREE-FORM tab. The prompt design page will change to the free-form mode. If prompted click Continue.
- In the Prompt field, delete any existing text and copy the following:
- Click on the SUBMIT button on the right side of the page.
The model will respond with the answer to the question (your response may vary):
Question Answering
- In the Prompt field, delete any existing text and copy the following:
- Click on the SUBMIT button on the right side of the page.
The model will respond with the answer to the question (your response may vary):
Text Classification
- In the Prompt field, delete any existing text and copy the following:
- Click on the SUBMIT button on the right side of the page.
The model will respond with the answer to the question (your response may vary):
-
On the top left, click Untitled Prompt and rename your prompt as
Text Classification
. -
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.
The saved prompt will appear at the MY PROMPTS tab.
Click Check my progress to verify the objectives.
Congratulations!
Congratulations! In this lab, you explored the capabilities of Vertex AI Studio for Healthcare. You analyzed an image and video with Gemini multimodal and designed prompts with free-form and structured mode. You also explored zero-shot, one-shot, and few-shot prompting, as well as learned how to generate text summarization, question answering, and text classification. You are now ready to leverage the power of generative AI models.
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 June 26, 2024
Lab Last Tested June 26, 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.