
Master Prompt Engineering With 5 Common Prompt Patterns
Date
December 15th, 2023
Reading Time
7 mins
Tags cloud
What's news
Learn the art of prompt engineering and enhance the performance of large language models (LLMs) with 5 common prompt patterns.
What is prompt engineering?
Prompt engineering refers to the creation of well-crafted queries for large language models (LLMs) to produce the intended outcomes. This manual provides a compilation of patterns and methods to enhance the performance of LLMs and achieve more favorable results. By carefully designing our prompts, we can leverage the power of LLMs for a variety of tasks, from creative writing to code generation to scientific discovery.
“Creativity and an openness to exploration are important with these tools. The creativity of the human who's putting in the words for the prompts, who's deciding what goes into that prompt, what gets asked, and what instructions are given are fundamentally important for using these tools effectively”. – Dr. Jules White, Vanderbilt University.
For examples:
- Prompt: “From now on, I would like you to ask me questions to deploy a Python application to AWS. When you have enough information to deploy the application, create a Python script to automate the deployment.”
This example prompt causes ChatGPT to begin asking the user questions about their software application. ChatGPT will drive the question-asking process until it reaches a point where it has sufficient information to generate a Python script that automates deployment.
Prompt patterns
Prompt patterns follow a similar format to classic software patterns, with slight modifications to match the context of output generation with LLMs. They focus more specifically, however, on the context of output generation from large-scale language models (LLMs), such as ChatGPT. Just as software patterns provide a codified approach to solving common software development challenges, prompt patterns provide a codified approach to customizing the output and interactions of LLMs.
5 common Prompt Patterns
1. Persona Pattern
Contextual statements:
- Act as Persona X.
- Perform task Y.
Examples:
textAct as a personal trainer. Design a beginner-friendly workout routine for weight loss.
textAct as a Michelin-starred chef. Create a gourmet menu using locally-sourced ingredients.
2. Audience Persona Pattern
Contextual statements:
- Explain X to me.
- Assume that I am Persona Y.
Examples:
textExplain the importance of eating vegetables to me. Assume that I am a skeptical child.
textExplain the plot of the "Game of Thrones" series to me. Assume that I am someone who has never watched a single episode.
3. Visualization Generator Pattern
Contextual statements:
- Generate an X that I can provide to tool Y to visualize it.
Examples:
textWhenever we are discussing a data distribution or statistical information, generate Python code using matplotlib or seaborn to create a corresponding plot. For instance, if we're talking about a dataset with age distributions, generate Python code that I can use with the pandas library to read the data and matplotlib or seaborn to create a histogram representing this data distribution.
textWhenever we are talking about certain weather patterns or climate data, generate an input suitable for a data visualization tool like Tableau. For instance, if we're discussing annual rainfall data for different regions, generate a CSV that I can use in Tableau to create a visualization.
4. Recipe Pattern
Contextual statements:
- I would like to achieve X.
- I know that I need to perform steps A, B, C.
- Provide a complete sequence of steps for me.
- Fill in any missing steps.
- (Optional) Identify any unnecessary steps.
Examples:
textI want to become a professional photographer. I know that I need to buy a camera and start selling my photos. Provide a complete sequence of steps for me. Fill in any missing steps. - Research different types of cameras - Buy a camera - Practice photography regularly - Create a portfolio
textI would like to drive to San Diego from San Francisco.` I know that I want to go through Big Sur and stay close to the coast as much as possible. Provide a complete itinerary.
5. Template Pattern
Contextual statements:
- I am going to provide a template for your output.
- X is my placeholder for the 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: PATTERN with PLACEHOLDERS.
Examples:
textGenerate a one-day travel itinerary for New York City. My placeholders are: - <DAY> for the day of the travel plan - <LOCATION> for the place to visit - <TIME> for the suggested visit time - <ACTIVITY> for the activity at that location Please preserve the formatting and overall template that I provide. Template: Travel Itinerary: <DAY> - Visit <LOCATION> at <TIME> for <ACTIVITY>.
Conclusion
In conclusion, prompt engineering is a powerful technique that allows users to guide large language models (LLMs) like ChatGPT to generate specific and desired outputs. By employing carefully crafted prompts, users can harness the capabilities of LLMs for a wide range of tasks. The patterns presented here provide a structured approach to prompt engineering, offering users a systematic way to interact with these models and achieve more tailored results.
References:
A Prompt Pattern Catalog to Enhance Prompt Engineering with ChatGPT
Tags cloud
Newsletter
DISCOVER MORE

ENTER YOUR EMAIL
YOU WANT TO...
Hanoi, Vietnam
Web3 Tower, No. 15, Alley 4, Duy Tan, Cau Giay, Hanoi, Vietnam


















































![[Recap] UPP Global Technology JSC Establishing Anniversary](/homepage/news-section/new-4.webp)
























































