Large language models and generative AI are extremely powerful because they allow us as humans to interact with AI tools in new ways we’ve never had before. But working with large language models, or LLMs, requires prompting. How we “design” our prompts – the order, the specificity, length, style, tone, and other aspects – are important to consider. We’ve led the teams that developed Prompt Builder and Einstein Studio, and we’ve gained critical learnings we’d love to share.
First, let’s define “prompts”: A prompt is what we call the message or “instructions” we submit to an LLM to be processed, thus giving us an answer or a “prompt response.” In natural language, we might say “question and answer.” When we refer to LLMs – deep-learning algorithms that perform a variety of natural language processing (NLP) tasks – it’s common to use “prompt and response” as the parallel terminology. Prompt design, or prompt engineering, is the practice we’re learning as we embark on this new way of working with machines and it’s a critical skill for our success interacting with AI.
Improving your prompt design
To be effective at prompting LLMs and getting good results, we must unlearn what we know about English conversations and writing. Talking to a computer is not the same as an exchange between two humans. Proper grammar and sentences that we would use with human interactions do not work as well when talking to machines. We have devised seven tips that can help you design powerful prompts:
- Know that AI doesn’t know you – Provide clear context on the who, what, and purpose of your prompt.
- Always bowl with bumpers – Provide guidelines or “policies” in your prompt to keep AI in its lane.
- Shuffle the playlist – The order or sequence of your instructions drastically impacts the response.
- Do and do not…you must try – Telling language models what not to do can be as important as what to do.
- Remember that all the world’s a stage – AI can play many parts, including a writer, actor, set designer, director, and more.
- Use the superhero of clarity: lists – Organize for impact by using lists or comma-separated values.
- Embrace the chaos and iterate – AI is unpredictable and moody, with fluid responses that rely on your prompt structure.
Let’s put these tips into context. Imagine a superhero team called The Friendly Force has a new member named Embracer. We want to use generative AI to write an introduction for Embracer.
Tip 1: Provide clear context (know that AI doesn’t know you)
Starting prompt:
I am Embracer.
Write an introduction to my new superhero team “The Friendly Force.”
Response:
In a world teetering on the brink of chaos, where darkness seems to creep into every corner of our lives, a beacon of hope emerges – “The Friendly Force.” Led by their enigmatic and empathetic leader, Embracer, this new superhero team has vowed to be the antidote to the despair that plagues our world. With a mission grounded in compassion and a commitment…
The response, truncated here, originally was 350 words. Notice how much freedom the LLM took in its response? It fabricated quite a few embellishments, most notably that it decided Embracer is the leader of the Friendly Force, though we never mentioned anything of the sort. Lastly, it’s introducing The Friendly Force, not Embracer. This is an example where not being specific enough can lead to vastly different results. Let’s see how we might improve this.
Tip 2: Set guidelines to keep the prompt in the right lane (always bowl with bumpers)
Like during bowling, adding bumpers to your lane drastically increases your chances of hitting the pins. Translating this analogy to an LLM, the bumpers are additional rules we include to “guide” the response.
Prompt v2:
I am Embracer.
Write an introduction to my new superhero team “The Friendly Force” as “Embracer.”
My superpowers are hugs and energy. 50 words.
Response:
Introducing the “Friendly Force”! Led by a diverse group of heroes, Embracer stands as the heart of the team. With the remarkable abilities to harness and project energy, Embracer’s warm hugs offer comfort and support in times of need. Together, they unite their unique powers to protect and uplift humanity.
While the response is better, the focus (still prioritizing the team) and order are still a bit off. Additionally, the LLM continues to center Embracer as the leader.
Tip 3: Sequence the prompt (shuffle the playlist)
When we create a music playlist, we tend to order our favorite songs toward the top so they play first. Similarly, language models tend to order and weigh the elements in the response based on the order in which they were received in the prompt.
Prompt v3:
Write me an introductory message as a superhero named Embracer to my superhero team “The Friendly Force.”
My superpowers are hugs and energy. 50 words.
Response:
Dear Friendly Force,
I am Embracer, thrilled to join our extraordinary team. My powers revolve around the warmth of hugs and harnessing boundless energy. I’m here to uplift and empower us all with love and vitality. Together, we’ll spread positivity and save the day!
Here we have done a bit of shuffling. We have moved the word “Embracer” so it appears before the team name of “Friendly Force.” We also changed “introduction” to “introductory message” to be more explicit. This is some great progress, yet the response still isn’t quite as good as it can be.
Tip 4: Tell the LLM what to avoid (do and do not…you must try)
Language models have a habit of hallucinating or literally making up convincing information. Generally, they’re not the best at saying, “I don’t know” – though this has gotten much better. In certain cases, it might be necessary to tell the LLM what not to do, in order to have a more accurate response. This can be done by informing the language model on words, phrases, and concepts to avoid. When we were making these prompts, the LLM had a habit of including very dark concepts, like doom and gloom.
Prompt v4:
Write me an introductory message as a superhero named Embracer to my superhero team “The Friendly Force.”
My superpowers are hugs and energy. 50 words.
Exclude words villany, darkness. Use a warm tone with positive, inclusive language.
Response:
Greetings, my extraordinary friends of the Friendly Force! I am Embracer, the radiant bearer of hugs and boundless energy. Together, we shall illuminate the world with our warmth, kindness, and unity. Let’s embrace our mission to spread love and light wherever we go! 💫🤗 #FriendlyForceUnite
Finally, the response is getting somewhere – and it even has a hashtag. Embracer is getting closer to an accurate introduction.
Tip 5: LLMs can play many roles (remember that all the world’s a stage)
LLM’s can take on many roles: an actor, a director, a writer, and more. It can be interesting to experiment with telling language models to behave like or write in the style of a specific person. Now, we might not want to do this for our superhero introduction, but this concept is worth illustrating as language models are good at this.
Prompt v5:
Write me an introductory message as a superhero named Embracer to my superhero team “The Friendly Force.”
My superpowers are hugs and energy. 50 words.
Exclude words villany, darkness. Use a warm tone with positive, inclusive language.
In the style of Dr. Seuss.
Response:
Greetings, dear Friendly Force, with hearts all aglow,
I’m Embracer, your ally, with love to bestow.
My powers are hugs, so warm and so tight,
And energy flows from me day and night.
Together we’ll spread joy, make the world shine so bright,
With kindness and love, we’ll win every fight!
In this output, the Dr. Seuss-inspired poetic phrase and verse-styled response is clear.
Tip 6: Use lists (use the superhero of clarity: lists)
As we mentioned previously, when working with LLMs we have to try and forget our spoken language formalities that we would apply to human-to-human interactions. LLMs appreciate a much more concise form of input. Bulleted lists, comma-separated values, key-value pairs, and even JSON data work really well for prompt design.
Prompt v6:
Task: Write an introductory message
Topic: Excited to be part of the team
My Name: Embracer
Superpowers: hugs, energy
Team: Friendly Force
Exclude words: villain, dark
Style: creative
Tone: donfident, energetic
Length: 50 words
Response:
Hey Team Friendly Force! 🌟 Embracer here, thrilled to join our radiant crew! With superpowers fueled by hugs and boundless energy, I’m all about spreading positivity and light. Let’s ignite our teamwork and brighten the world together! 💪🌈 #EmbraceTheEnergy #FriendlyForceUnite
The response is looking great! Embracer finally has a well-constructed response. It’s cohesive, clear, and even includes hashtags and emojis.
Tip 7: Iterate on the response (embrace the chaos and iterate)
For any given prompt, the response is almost always going to vary to some degree. This is especially true if you give the same prompt multiple times within the same chat session. It happens because most language models take in the context of the historical exchange of dialogue.
Prompt v7:
Write me an introduction as “Embracer” to my superhero team the “Friendly Force.” My superpowers are Hugs and energy. I am not the leader. 40 words.
Response 1:
Greetings, dear souls of compassion and warmth! I am Embracer, a humble member of the extraordinary superhero collective known as the “Friendly Force.” With the power of hugs and boundless energy, I stand ready to
Response 2:
Greetings, compassionate souls! I am Embracer, a member of the remarkable superhero team, the “Friendly Force.” With the power of heartfelt hugs and boundless energy, I stand ready to spread warmth and kindness…
To prevent this behavior, you can clear out the current chat session or start a new chat session and give it the same prompt. This iterative mindset is an integral piece of the prompt design process.
From the initial Embracer prompt to the final prompt and output, it’s been a journey. We’re all still learning how best to talk to language models and use the ever-growing field of new AI tools. So stay curious and have fun.