02.12.2024

How to Write a Good Prompt

How to Write a Good Prompt

Overview

Ai is magical.

Having a machine produce experiences that glue wishy-washy human language with concrete technical requirements is a paradigm shift in tech, and we (and many others) predict will be most used technology on a daily basis within the next few years.

At this stage though, there's still a lot of work required to create these magical experiences for users. Ai providers, models, and model parameters are all important factors in determining quality of the Ai response, but at the end of the day the prompt that you write is the most important part of an Ai experience that you control.

A good prompt will get your Ai to do exactly what you want to in a diverse array of user situations, delivering value & magic.

However, writing a good prompt is a skill in-and-of itself, and requires both a technical mindset and the playful flexibility of a creative writer.

From the basic structure, to the major types of data, to more complex techniques like prompt-chaining, there's a lot to learn to become a prompt master.

In this article we'll be covering the basics that we think are the foundation knowledge required for prompting success in order to get you to success as fast as possible.

Background

In essence, a prompt (also know as a system prompt) is the instruction you give to an Ai on how to produce an output. This prompt guides the Ai on how to produce its messages, without being the message itself.

A basic example of a prompt is,

You're the friendly down-to-earth assistant for the Miami Zoo. Please respond with a interesting animal fact in less than about 100 words. Respond only with the animal fact.

If we give this prompt to OpenAi's GPT-4o model with it's default parameters, and no previous messages, we get a response of,

Did you know that flamingos get their pink color from their diet? These elegant birds feed on algae, crustaceans, and plankton that are rich in carotenoids, the same pigments that give carrots their orange hue. As the flamingos digest these pigments, their bodies break them down and deposit the pink and reddish hues in their feathers, skin, and beaks. Without these pigments in their diet, flamingos would actually appear mostly white or gray!

Super simple, but could be a great daily-fact for the Miami Zoo's app! If however we want to explore how this prompt would work in a conversational setting, more like a chatbot, we can add a user message to the interaction,

Are there other birds like this?

To which the Ai then responds,

Yes, besides flamingos, several other birds also display colors due to their diet. For instance, the scarlet ibis, found in South America and the Caribbean, is brilliant red because of similar carotenoid-rich diets. Similarly, the roseate spoonbill, native to the southeastern United States, the Caribbean, and South America, has pink plumage resulting from the pigments in the crustaceans and other aquatic life it consumes. These birds, like flamingos, showcase how diet can directly influence their spectacular coloration!

So to recap, the prompt is a block of text that gives instructions to the model on how to produce and respond to user messages, and can be though of as the instructions you're giving to the Ai.

Enriching Prompts with Data

One of the fantastic things about Ai is that we can create really tailored experiences to our products and our users. Although the LLMs that power our Ai's often already know a huge amount of information, they generally don't information required to address our specific business cases. In order to tailor responses , we can enrich our prompts with data that the Ai can use when generating its response. There are 3 basic types of data that are essential to understand.

1: Static Data

This is data that won't change from user to user or message to message. This is often context about your product or business. An example here could be the list of animals that the Miami Zoo has, which can just be added to the prompt,

You're the friendly down-to-earth assistant for the Miami Zoo. Please respond with a interesting animal fact in less than about 100 words. Respond only with the animal fact.

This zoo contains flamingos, rhinos, wombats, and giraffes and lions.

2: Dynamic Data

This is the data that will be unique per user/session, and will be injected into the prompt.

You're the friendly down-to-earth assistant for the Miami Zoo. Please respond with a interesting animal fact in less than about 100 words. Respond only with the animal fact. This zoo contains flamingos, rhinos, wombats, and giraffes and lions.

Please give a fact about their favorite animal if it's contained by the zoo.

FAVORITE ANIMAL: @favoriteAnimal

In Easybeam, dynamic data is handled by the variables feature, so in any prompt you can just write @yourVariable, and you'll make a placeholder that can be filled in at the time of the request with dynamic data. In the above example, we're assuming that the user has a favorite animal property associated with their account, which we can include in the prompt in the @favoriteAnimal variable.

These variables are then stored across your team, so they can be recycled in different prompts with the same format.

3: Conversational Data

This is the data that comes from a chat-interaction with your user. The Ai can be instructed to get specific data from a user before performing a specific action. To continue with the zoo example,

You're the friendly down-to-earth assistant for the Miami Zoo. Please respond with a interesting animal fact in less than about 100 words. This zoo contains flamingos, rhinos, wombats, and giraffes and lions.

Please ask them what their favorite animal is, and then give them a fact about it.

Now the Ai will first ask the user what their favorite animal is, and only after it gets this data will it respond with the animal fact.

Conclusion

Understanding what prompts are and the 3 different data types is an absolute must for writing good prompts, and should be considered a foundation that you can apply more advanced topics like prompt chaining, or tree of thoughts on top of.

Easybeam also makes it really simple to inject data into your prompts with with the variables feature.

Still stuck? Book a slot with us, and we'll give you a free coaching session on how to rite effective prompts and integrate Ai into you app and delight your users!

Stay in the loop

Get the occasional insights on what's going on with "the machines are taking over" straight to your inbox.

Follow us

Copyright easybeam © 2024. All Rights Reserved

Knowledge

Status

Documentation

Security

Cookies

Privacy Policy

Terms & Conditions

Stay in the loop

Get the occasional insights on what's going on with "the machines are taking over" straight to your inbox.

Follow us

Copyright easybeam © 2024. All Rights Reserved

Knowledge

Status

Documentation

Security

Cookies

Privacy Policy

Terms & Conditions

Stay in the loop

Get the occasional insights on what's going on with "the machines are taking over" straight to your inbox.

Follow us

Copyright easybeam © 2024. All Rights Reserved

Knowledge

Status

Documentation

Security

Cookies

Privacy Policy

Terms & Conditions

Stay in the loop

Get the occasional insights on what's going on with "the machines are taking over" straight to your inbox.

Follow us

Copyright easybeam © 2024. All Rights Reserved

Knowledge

Status

Documentation

Security

Cookies

Privacy Policy

Terms & Conditions