arrow_back

Prompt Design in Vertex AI: Challenge Lab

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

Prompt Design in Vertex AI: Challenge Lab

Lab 1 hour 30 minutes universal_currency_alt No cost 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

GSP519

Google Cloud self-paced labs logo

Overview

In a challenge lab you’re given a scenario and a set of tasks. Instead of following step-by-step instructions, you will use the skills learned from the labs in the course to figure out how to complete the tasks on your own! An automated scoring system (shown on this page) will provide feedback on whether you have completed your tasks correctly.

When you take a challenge lab, you will not be taught new Google Cloud concepts. You are expected to extend your learned skills, like changing default values and reading and researching error messages to fix your own mistakes.

To score 100% you must successfully complete all tasks within the time period!

This lab is recommended for students who have enrolled in the Prompt Design in Vertex AI and Gemini course. Are you ready for the challenge?

Topics tested

  • Craft effective prompts and use parameters to guide generative AI output in Vertex AI Studio.
  • Apply Gemini models to create product descriptions and taglines in a real-world marketing scenario.
  • Examine and run Python code exported from Vertex AI Studio to gain a basic understanding of generative AI implementation.
  • Use Jupyter Notebooks to test and modify generative AI code.

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.

Challenge Scenario

You're a member of an educational content startup specializing in engaging learners with the natural world. You've formed a partnership with Cymbal Direct, an online retailer launching a new line of outdoor gear and apparel designed to encourage young people to explore and connect with nature.

Cymbal Direct wants to create a marketing campaign for its new product line that leverages the power of generative AI. Your task is to help them develop a set of tools within Google Cloud's Vertex AI platform that will streamline the generation of the following:

  • Evocative Product Descriptions: using image analysis to inspire short, descriptive text that captures the essence of their products and the feeling of being in nature.
  • Catchy Taglines: focused on highlighting product features, the target audience, and the desired emotional response.

Task 1. Build a Gemini image analysis tool

In this section, you will create a template for analyzing images of Cymbal Direct products using the Gemini 1.5 Pro model in Vertex AI Studio. The goal is to generate descriptive text options inspired by the image, from simple details to more evocative, mood-setting phrases.

Tasks:

  1. Before you begin, download the image provided for this task. The following image is a product from Cymbal Direct. Right-click and select Save image as to save the image to your local machine.

backpack on a trail

  1. Use Vertex AI Studio's Freeform interface with the gemini-1.5-pro model to analyze Cymbal Direct's product image (provided) and generate multiple descriptive text options inspired by the image.

  2. Experiment with different prompts to generate the following:

    • Short, descriptive text inspired by the image.
    • Catchy phrases suitable for advertisements.
    • A poetic description for a nature-focused campaign.
  3. Evaluate and Iterate: adjust your prompt and parameters as needed to refine the results.

  4. Name your prompt Cymbal Product Analysis.

  5. Save Prompt: Once you're happy with the results, click Save, and select the region.

Note: Ensure you are using the gemini-1.5-pro model for this task! Build a Gemini image analysis tool.

Task 2. Build a Gemini tagline generator

In this task, you will create a freeform prompt for generating diverse tagline possibilities using the Gemini 1.5 Pro model in Vertex AI Studio. The goal is to develop a prompt that allows for customization of the tagline style, based on product attributes, target audience, and emotional resonance.

Tasks:

  1. Create a new Freeform prompt with the gemini-1.5-pro model to create a customizable tagline generator for Cymbal Direct's new product line.

  2. In the System instructions box, enter the following:

Cymbal Direct is partnering with an outdoor gear retailer. They're launching a new line of products designed to encourage young people to explore the outdoors. Help them create catchy taglines for this product line.
  1. Include 2 Examples in your prompt to guide the output style. An example input and output are provided below for reference:
Input Output
Write a tagline for a durable backpack designed for hikers that makes them feel prepared. Consider styles like minimalist. Built for the Journey: Your Adventure Essentials.
  1. Design a Freeform Prompt with parameters to customize taglines based on:

    • Product attributes (e.g., durable, lightweight)
    • Target audience (e.g., young adventurers, families)
    • Emotional resonance (e.g., empowered, connected)
  2. In the Test box, add one input and click the submit button to have Gemini generate a tagline option based on your prompt.

  3. Evaluate and Iterate:

    • Experiment with different parameter combinations to see the variety of taglines produced.
    • Based on the results, fine-tune the wording of your prompt, add more parameter options, or adjust the style choices to achieve your desired outcome.
  4. Name your prompt Cymbal Tagline Generator Template.

  5. Save Prompt: Once you're happy with the results, click Save, and select the region.

Note: Ensure you are using the gemini-1.5-pro model for this task! Build a Gemini tagline generator.

Task 3. Experiment with image analysis code

In this task, you will explore the Python code for the image analysis prompt you created. You will then modify the prompt to be more specific and test the new prompt in a notebook.

  1. In the Google Cloud Console, on the Navigation menu, click Vertex AI > Workbench.

  2. On the Instances page, find the generative-ai-jupyterlab notebook and click on the Open JupyterLab button.

  3. Create a new notebook file named image-analysis.ipynb.

Explore the image analysis code

  1. From the Vertex AI Studio page, navigate to the Saved Prompts page. Select the Cymbal Product Analysis prompt you created.

  2. On the right side of the prompt, click Get Code. Use Python as the language.

Note: The first code block uses terminal commands to install the necessary Python packages. You can run these commands in a terminal or in a notebook cell. If you run them in a notebook cell, you must include the ! character at the beginning of each command. In this scenario, run the first code block in the terminal by navigating to the File > New > Terminal.
  1. Run the second code cells in the notebook. Verify that the code executes successfully and produces the expected output.

Modify the image analysis prompt

  1. Within the code, there will be a line of text between triple quotes ("""). This is your current image analysis prompt. For example, it might be:
"""Describe this image with a focus on colors, textures, and the feeling it evokes."""
  1. Now you will modify the prompt to be more specific. Change the wording of the prompt in the code cell to make the output less than 10 words.

  2. Next, modify the prompt code to encourage the model to produce the most creative, unusual, and unexpected descriptions of the image it can think of.

Hint: You will need to adjust one of the parameters in the code to achieve this!
  1. Save the changes to your code. Then, rerun the code cell in your notebook to test Gemini with the new prompt.

  2. Verify that the new descriptions are shorter and more creative than the previous ones.

Experiment with image analysis code.

Task 4. Experiment with tagline generation code

In this task, you will explore the Python code for the tagline prompt you created. You will then modify the prompt to include a specific keyword and test the new prompt in a notebook.

  1. Create a new notebook file named tagline-generator.ipynb.

  2. Add the following code to the notebook:

from vertexai.preview.generative_models import GenerativeModel model = GenerativeModel("gemini-1.5-pro") prompt = """ Cymbal Direct is partnering with an outdoor gear retailer. They\'re launching a new line of products designed to encourage young people to explore the outdoors. Help them create catchy taglines for this product line. input: <your example input #1> output: <your example output #1> input: <your example input #2> output: <your example output #2> input: <your test input> output: """ responses = model.generate_content( prompt, generation_config={ "temperature": 1, "max_output_tokens": 2048, "top_p": 1.0, "top_k": 40, }, stream=True ) for response in responses: print(response.text)
  1. Update the placeholders <your example input> with the example inputs from your tagline prompt and <your example output> with the example outputs from your tagline prompt. Also, update <your test input> with your test input.

The examples and test inputs should be be copied from your Cymbal Tagline Generator Template prompt, which you can find in the Saved Prompts page in Vertex AI Studio.

  1. Run the code cell in the notebook. Verify that the code executes successfully and produces the expected output.

Modify the tagline generation prompt

  1. Within the code, there will be multiple lines of text between triple quotes ("""). This is your current tagline generation prompt.

  2. Now you will modify the prompt to include a specific keyword. Modify the last input to specifically request that the tagline includes the keyword nature.

  3. Save the changes to your code. Then, rerun the code cell in your notebook to test the language model with the new prompt.

  4. Verify that the new tagline includes the keyword nature.

Experiment with tagline generation code. Note: Wait for couple of minutes and click the check my progress button if you are not getting the score.

Congratulations!

Congratulations, you've successfully completed the lab! You've helped Cymbal Direct create a set of tools within Google Cloud's Vertex AI platform that will streamline the generation of evocative product descriptions and catchy taglines for their new product line. You've also explored and modified the image analysis and tagline generation code in a notebook. Great job!

Prompt Design in Vertex AI skill badge

Next steps / Learn more

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 August 30, 2024

Lab Last Tested August 30, 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