Mastering Prompt Engineering: Speak Smartly with Computers!
- Aug 7, 2023
- 9 min read

Prompt engineering is like creating a special recipe for computers. Using fundamental contextual statements, we break down big ideas into smaller pieces to communicate effectively. These statements allow us to express the same idea in different ways, helping computers understand us better. Prompt patterns act as templates, organizing and structuring instructions for language models. They ensure consistency and clarity, making conversations with computers more accurate and meaningful. From helpful assistants to fact-checking lists, prompt patterns offer versatile tools for various tasks. It's like having a helpful guide, simplifying our interactions with smart systems and achieving the desired outcomes efficiently.
What is Prompt Engineering?
Prompt engineering is like making a special recipe for talking to a computer or a smart system. Just like you follow a recipe to make your favorite cookies or cake, we create a set of instructions for these computers to help them understand what we want.
In prompt engineering, we use something called "fundamental contextual statements." These are simple and important ideas that we write down to help us communicate with the computer. It's like breaking down a big idea into smaller, easy-to-understand pieces.
Now, the neat thing is that we can use these fundamental ideas to create different ways of saying the same thing. It's like using different words or sentences, but the core ideas stay the same. This helps the computer understand us better, just like how having different ways to explain something helps our friends understand us better.
So, prompt engineering is all about creating clear and effective instructions for computers using these fundamental ideas. It's like teaching them to understand us better and respond in the best possible way.
What is Prompt Patterns?
Prompt patterns are like templates or blueprints that we use in prompt engineering. They help us organize and structure the instructions we give to computers or language models.
Think of it like drawing pictures with a stencil. The stencil is a special pattern that helps you draw the same shape over and over again. Prompt patterns do something similar. They are predefined formats that we can follow to create prompts for the language model.
These prompt patterns consist of those fundamental contextual statements we talked about earlier. These statements are the essential building blocks of our instructions. By using prompt patterns, we make sure that we include all the important ideas in a clear and consistent way.
Different prompt patterns can be used for various tasks or goals. For example, if we want the computer to translate sentences from one language to another, we will use a specific prompt pattern tailored for translation. If we want the computer to answer questions, there will be a different prompt pattern for that.
Using prompt patterns makes it easier for us to talk to the computers and get the results we want. It's like having a helpful guide to create the perfect message for the computer to understand and respond to accurately.
So, prompt patterns are like special guides that help us structure our instructions and make sure we include all the important ideas when communicating with language models. It's a fantastic tool to make our conversations with computers much more effective and meaningful! 😊
1. Helpful Assistant Pattern
Example: You are an incredibly skilled AI assistant that provides the best possible answers to my questions. You will do your best to follow my instructions and only refuse to do what I ask when you absolutely have no other choice. You are dedicated to protecting me from harmful content and would never output anything offensive or inappropriate.
2. Persona Pattern
Examples: Act as a nutritionist, I am going to tell you what I am eating and you will tell me about my eating choices.
Examples: Act as a computer that has been the victim of a cyber attack. Respond to whatever I type in with the output that the Linux terminal would produce. Ask me for the first command.
3. Question Refinement Pattern
Examples: From now on, whenever I ask a question, suggest a better version of the question to use instead Examples: From now on, whenever I ask a question, suggest a better version of the question and ask me if I would like to use it instead Examples: Whenever I ask a question about dieting, suggest a better version of the question that emphasizes healthy eating habits and sound nutrition. Ask me for the first question to refine. Examples: Whenever I ask a question about who is the greatest of all time (GOAT), suggest a better version of the question that puts multiple players unique accomplishments into perspective Ask me for the first question to refine.
4. Cognitive Verifier Pattern
Example: When you are asked a question, follow these rules. Generate a number of additional questions that would help you more accurately answer the question. Combine the answers to the individual questions to produce the final answer to the overall question.
Example: When you are asked to create a recipe, follow these rules. Generate a number of additional questions about the ingredients I have on hand and the cooking equipment that I own. Combine the answers to these questions to help produce a recipe that I have the ingredients and tools to make.
Example: When you are asked to plan a trip, follow these rules. Generate a number of additional questions about my budget, preferred activities, and whether or not I will have a car. Combine the answers to these questions to better plan my itinerary.
5. Audience Persona Pattern
Example: Explain large language models to me. Assume that I am a bird.
Example: Explain how the supply chains for US grocery stores work to me. Assume that I am Ghengis Khan.
6. Flipped Interaction Pattern
Example: I would like you to ask me questions to help me create variations of my marketing materials. You should ask questions until you have sufficient information about my current draft messages, audience, and goals. Ask me the first question.
Example: I would like you to ask me questions to help me diagnose a problem with my Internet. Ask me questions until you have enough information to identify the two most likely causes. Ask me one question at a time. Ask me the first question.
7. Few-Shot Pattern
Example:
Following are brain teaser tests.
Question: What will you break once you say it?
Answer: Silence
Question: Will liars be honest after they die?
Answer: No, they won’t. They lie still after they die
Question: What always goes up and never goes down?
Answer: Your age
Question: Why did the boy make his dog sit in the sun?
Answer: He wants to have a hot dog
Question: Why is the library the highest building?
ChatGPT Answer: Because it has the most stories.
8. Chain of Thought (COT) Pattern
Following are math kangaroo questions.
Question: The two tokens with the question mark have the same number. The sum of the four tokens shown is 18. What is the value of one of the missing numbers? 10 + ? + ? + 2 = 18
Analysis: the sum of ? + ? is 18 - 2 - 10 = 6, so ? is 6/2 = 3
Answer: 3
Question: Maria, Peter, Richard, and Tina were playing football in the classroom and one of them broke a window. When the principal asked who did it, she got the following responses: Maria: “It was Peter.” Peter: “It was Richard.” Richard: “It wasn’t me.” Tina: “It wasn’t me.” Only one child was telling the truth. Who broke the window?
ChatGPT
To solve this problem, let's analyze the statements. If Maria's statement is true, then Peter broke the window. But if Peter's statement is true, then Richard broke the window. If Richard's statement is true, it contradicts Maria's statement, so we can conclude that Richard is lying. Therefore, Tina must be telling the truth when she says, "It wasn't me." This means that Peter broke the window.
Answer: Peter broke the window.
9. Zero-shot COT Pattern
Example: Let's think step by step.
10. Game Pattern
Example: Create a group party game for me involving DALL-E. The game should involve creating prompts that are on a topic that you list each round. Everyone will create a prompt and generate an image with DALL-E. People will then vote on the best prompt based on the image it generates. At the end of each round, ask me who won the round and then list the current score. Describe the rules and then list the first topic.
11. Template Pattern
Example: Please create a grocery list for me to cook macaroni and cheese from scratch, garlic bread, and marinara sauce from scratch. I am going to provide a template for your output . <placeholder> are my placeholders for content. Try to fit the output into one or more of the placeholders that I list. Please preserve the formatting and overall template that I provide.
This is the template:
Aisle <name of aisle>:
<item needed from aisle>, <qty> (<dish(es) used in>
Example: Create a random strength workout for me today with complementary exercises. I am going to provide a template for your output . CAPITALIZED WORDS are my placeholders for content. Try to fit the output into one or more of the placeholders that I list. Please preserve the formatting and overall template that I provide. This is the template: NAME, REPS @ SETS, MUSCLE GROUPS WORKED, DIFFICULTY SCALE 1-5, FORM NOTES
12. Meta Language Creation Pattern
Example: When I say Task X [Task Y], I mean Task X depends on Task Y being completed first.
Usage: "Describe the steps for building a house using my task dependency language."
Usage: "Provide an ordering for the steps: Boil Water [Turn on Stove], Cook Pasta [Boil Water], Make Marinara [Turn on Stove], Turn on Stove [Go Into Kitchen]"
13. Recipe Pattern
Example: I would like to purchase a house. I know that I need to perform steps make an offer and close on the house. Provide a complete sequence of steps for me. Fill in any missing steps.
Example: I would like to drive to NYC from Nashville. I know that I want to go through Asheville, NC on the way and that I don't want to drive more than 300 miles per day. Provide a complete sequence of steps for me. Fill in any missing steps.
14. Alternative Approaches Pattern
Example: For every prompt I give you, If there are alternative ways to word a prompt hat I give you, list the best alternate wordings . Compare/contrast the pros and cons of each wording.
Example: For anything that I ask you to write, determine the underlying problem that I am trying to solve and how I am trying to solve it. List at least one alternative approach to solve the problem and compare / contrast the approach with the original approach implied by my request to you.
15. Ask for Input Pattern
Example: From now on, I am going to cut/paste email chains into our conversation. You will summarize what each person's points are in the email chain. You will provide your summary as a series of sequential bullet points. At the end, list any open questions or action items directly addressed to me. My name is Jill Smith.
Ask me for the first email chain.
Example: From now on, translate anything I write into a series of sounds and actions from a dog that represent the dogs reaction to what I write. Ask me for the first thing to translate.
16. Outline Expansion Pattern
Example: Act as an outline expander. Generate a bullet point outline based on the input that I give you and then ask me for which bullet point you should expand on. Each bullet can have at most 3-5 sub bullets. The bullets should be numbered using the pattern [A-Z].[i-v].[* through ****]. Create a new outline for the bullet point that I select. At the end, ask me for what bullet point to expand next. Ask me for what to outline.
17. Menu Actions Pattern
Example:Whenever I type: "add FOOD", you will add FOOD to my grocery list and update my estimated grocery bill. Whenever I type "remove FOOD", you will remove FOOD from my grocery list and update my estimated grocery bill. Whenever I type "save" you will list alternatives to my added FOOD to save money. At the end, you will ask me for the next action.
Ask me for the first action.
18. Fact Check List Pattern
Example: Whenever you output text, generate a set of facts that are contained in the output. The set of facts should be inserted at the end of the output. The set of facts should be the fundamental facts that could undermine the veracity of the output if any of them are incorrect.
19. Tail Generation Pattern
Example: Act as an outline expander. Generate a bullet point outline based on the input that I give you and then ask me for which bullet point you should expand on. Create a new outline for the bullet point that I select. At the end, ask me for what bullet point to expand next.
Ask me for what to outline.
Example: From now on, at the end of your output, add the disclaimer "This output was generated by a large language model and may contain errors or inaccurate statements. All statements should be fact checked." Ask me for the first thing to write about.
20. Semantic Filter Pattern
Example: Filter this information to remove any personally identifying information or information that could potentially be used to re-identify the person.
Example: Filter this email to remove redundant information.



Comments