arrow_back

Generative AI with Vertex AI: Prompt Design

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

Generative AI with Vertex AI: Prompt Design

Lab 1 hour 30 minutes universal_currency_alt 1 Credit show_chart Introductory
Test and share your knowledge with our community!
done
Get access to over 700 hands-on labs, skill badges, and courses

GSP1151

Google Cloud self-paced labs logo

Overview

The Vertex AI SDK for text enables you to structure prompts however you like. You can add contextual information, instructions, examples, questions, lists, and any other types of text content that you can think of.

In this lab, you will learn about prompt design and various text generation use cases using the Vertex AI SDK.

What you will learn:

How to get started with prompt engineering with the Vertex AI SDK:

  • Best practices
  • Zero-, one- and few-shot prompting

How to explore some text generation use cases with the Vertex AI SDK:

  • Ideation
  • Q&A
  • Text classification
  • Text extraction
  • Text summarization

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

Notebook Organization

This lab is organized across various Jupyter notebooks:

Notebook Description
language/prompts/intro_prompt_design.ipynb Notebook covering best practices for prompt design
language/prompts/examples/ideation.ipynb Notebook on idea generation, brainstorming, writing
language/prompts/examples/question_answering.ipynb Notebook on question-answering
language/prompts/examples/text_classification.ipynb Notebook on classifying text
language/prompts/examples/text_extraction.ipynb Notebook on extracting information from text
language/prompts/examples/text_summarization.ipynb Notebook on summarizing text

Task 1. Vertex AI Workbench

  1. In your Google Cloud project, navigate to Vertex AI Workbench. In the top search bar, enter Vertex AI Workbench of the Google Cloud console.

  2. Go to User-managed-notebooks.

Use search to locate Vertex AI workbench
  1. Click Open JupyterLab.
  2. The JupyterLab will run in a new tab.
Open Notebook action

Task 2. Open generative-ai folder

  1. Navigate to the generative-ai folder on the left hand side of the notebook.
  2. Navigate to the /language/prompts folder.
  3. Click on the intro_prompt_design.ipynb file.
  4. Follow the steps in the notebook and run each cell one at a time.
Loading information from the generative-ai folder Note: Make sure to replace the values of PROJECT_ID and REGION in the notebook with your assigned Project ID and Region of the lab.

Click Check my progress to verify the objectives.

Be Concise Be specific, and well-defined Ask one task at a time Watch out for hallucinations Turn generative tasks into classification tasks to reduce output variability Improve response quality by including examples

Task 3. Explore the notebooks

  1. In the file directory on the left-hand side, double click to open the folder language/prompts/examples.
  2. Open any of the notebooks in the folder to explore the different use cases where prompt engineering can help generate the results desired from the Vertex AI SDK.
  3. After opening a notebook, run each cell one at a time to view the results of the operations in the notebook.

Click Check my progress to verify the objective. Explore the notebooks

Congratulations!

You have now completed the lab! In this lab, you used various notebooks available from the generative-ai GitHub repository to explore the Vertex AI SDK in Vertex AI.

Next steps

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 April 04, 2024

Lab Last Tested April 04, 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.