Creating text prompts with Google AI Studio and the Gemini LLM

1. Introduction

Google AI Studio is a web-based tool for prototyping and experimenting with prompt engineering and the Gemini API is our latest LLM which can be selected as your model via Google AI Studio.

In this codelab, you will learn how to use Google AI Studio with Gemini to prototype various prompts to contribute to a single business use case: AI generated email responses for customer support queries. We will achieve this by exploring Google AI Studio's 3 text-based prompting tools.

Prerequisites

What you'll learn

  • The basics of prompt engineering.
  • How to use Google AI Studio and its three core text prompt prototyping tools.

2. Prompts in Google AI Studio

Google AI Studio is a tool for prototyping and experimenting with prompt engineering.

The tool gives us three different types of prompting to test, including:

  • Freeform prompt - a freeform way to experiment
  • Structured prompt - a table that users rows and columns to organize prompts
  • Chat prompt - a template for back-and-forth chatbot conversations

We'll start by creating a simple freeform text prompt experiment that we will expand into a Structured prompt and later a Chat prompt.

3. Business problem

In this experiment, we'll imagine ourselves as a business that is aiming to scale their customer relations support. Many businesses employ staff who read customer emails and write support responses. What if we could harness the power of AI to make the life of these support staff more efficient and easier?

Let's try a simple Freeform prompt to generate a support response as output based on an incoming customer email as input.

First, navigate to Google AI Studio:

https://makersuite.google.com/

You'll need to sign in with a valid Google account.

After logging in, click the "Create new" button and then select "Freeform prompt".

c81d68bb4746f823.png

4. Freeform prompt

You should now see this UI:

892d5d86502dec56.png

In the main text area, try inputting the following prompt and click "Run" to see the response:

Write a tech support email response for this question:

"I can't use my emails and passwords in Chrome."

What's interesting about the type of response that Google AI Studio responds with is that by mentioning "email" it has given a more complicated response that's formatted for an email. Furthermore, the response is likely verbose and detailed and based on text examples from all sorts of datasets that Gemini has access to.

But if we are a company that has been operating for years in email support, it's logical that we would have historical data of customer emails and the responses our support staff have written.

Let's look at how the Structured prompt can be leveraged in this scenario.

5. Structured prompt

In the second type of prompt, the Structured prompt, we can enter prompt examples as inputs and outputs for Gemini to generate.

Create a Structured prompt via the menu again here:

2aabb51eee6981a7.png

Let's imagine some hypothetical historical data. In fact, let's assume that some of this data has more than just customer email input and employee response output. Let's assume that old customer emails have been tagged with other information such as the device they were sent from and what type of question they've been categorized as by the employees.

Under the heading "Write your prompt examples", try creating a 2 column input and 2 column output data set for your Structured prompt:

ad356b186b59432b.png

Using the following data:

device

question

type

answer

iPhone

I can't use my emails and passwords in Chrome.

authentication

Have you checked that you're logged into Chrome with your Google account?

Android

My apps aren't syncing between my Android devices.

authentication

Have you checked that you're using the same Google account on both devices?

Android

I can't watch certain content on YouTube in other countries. What's the problem?

youtube

Videos can have different availability and copyright restrictions in different countries.

iPhone

Google Maps doesn't show me any public transport options in my area but we have buses.

maps

Thank you for letting us know! You can file a ticket here to raise issues regarding transportation accuracy.

By providing the above prompt examples, we can now enter in a more structured prompt that includes an argument for the device input and an argument for the question input. We accompany these prompt examples with an overall prompt to power the request:

Compose an email response for a tech support provider.

Now enter some structured input data under the heading "Test your prompt":

5649c02dc0a04727.png

device

question

iPhone

On YouTube I see errors about copyright. Why?

Android

On Android I saw a video complaining it was not available.

iPhone

I have problems seeing videos on YouTube while traveling and I can't log into Chrome at the moment.

Your response should look something like the following:

dbddbfeb9c9d89fb.png

We can see the type and answer columns for the first two rows. However, the final row has over indexed on the authentication component and neglected to mention copyright as a potential reason for the YouTube part of the customer's email.

If only we could easily reinforce our prompt examples with the first two rows from Gemini and perhaps influence . Actually, we can!

Hover over the first two rows and click the "Add to prompt examples" button.

c45aec5bf8e443ad.png

Afterwards, you should only have one test prompt left – the one which was previously the third row. Let's regenerate that response now that we've expanded our prompt examples.

And voila, with more examples of YouTube related questions provided in the prompt examples, the final test prompt received a more varied response from Gemini.

e009055eea5f06a8.png

This bodes well for our ability to provide prompt examples to our system for scaling our customer support queries. Before we conclude this codelab though, let's explore the Chat prompt prototyping experience.

6. Chat prompt

The third text prompting tool in Google AI Studio can be useful for testing conversational input and output responses. In the case of customer support this is also very relevant and using this you can test a full-blown conversation experience with Gemini for your customers.

You can add example inputs and outputs in the space below:

85220865c2c3dcbd.png

Here are some examples:

6f1d51aa23dc1d44.png

We could try the following test input:

I have problems seeing videos in Youtube while travelling and I can't log into Chrome at the moment

Your response might look something like this:

469a04b1c22d81db.png

Now that we've explored all three types of text prompts in Google AI Studio with Gemini we can reflect on the experiments.

7. Reflection

Ultimately, Google AI Studio is a web-based prototyping tool that lets you easily craft, test and save experiments with the various Google LLM's like the Gemini. In fact, Google AI Studio has 3 prototyping tools for text input and output with more tools in development for Gemini's multimodal features.

The Freeform prompt tool is the simplest and most freeform of the three tools. You simply write a single freeform text prompt and receive an answer.

While the Structured prompt tool allows you to provide prompt examples in the format of a table of example inputs and expected outputs.

Finally, the Chat prompt tool allows you to provide conversational prompt examples which takes the form of simple question and answer pairings.

Experimenting with a problem using all three tools can be helpful to find the optimal way to approach finding an LLM powered solution to your task.