ChatGPT Prompt Engineering Tactics — Quick Reference Guide

Peter Duy Tran
8 min readJun 18, 2023

--

This is a summary of very useful tactics from the ChatGPT Prompt Engineering for Developers course by Isa Fulford and Andrew Ng that you can learn for free on Deeplearning.ai.

Tactic 1: Use delimiters to clearly indicate distinct parts of the input

Prompt: 
Summarize the text below into a single sentence.
"You should express what you want a model to do by providing instructions that are as clear and specific as you can possibly make them."


Answer:
Clear and specific instructions are crucial when expressing desired actions for a model's behavior.

Tactic 2: Ask for a structured output

Prompt:
Generate a list of three made-up book titles along with their authors and genres. Provide them in JSON format with the following keys: book_id, title, author, genre.


Answer:
{
"books": [
{
"book_id": 1,
"title": "The Enigma of Time",
"author": "Evelyn Sinclair",
"genre": "Science Fiction"
},
{
"book_id": 2,
"title": "Whispers in the Wind",
"author": "Nathan Anderson",
"genre": "Mystery"
},
{
"book_id": 3,
"title": "Beyond the Horizon",
"author": "Isabella Bennett",
"genre": "Fantasy"
}
]
}

Tactic 3: Ask to check whether conditions are satisfied

Prompt:
You will be provided with text delimited by triple quotes. If it contains a sequence of instructions, re-write those instructions in the following format:

Step 1 - ...
Step 2 - ...
...
Step N - ...

If the text does not contain a sequence of instructions, then simply write "No steps provided."

"""
Making a cup of tea is easy! First, you need to get some water boiling. While that's happening, grab a cup and put a tea bag in it. Once the water is hot enough, just pour it over the tea bag. Let it sit for a bit so the tea can steep. After a few minutes, take out the tea bag. If you like, you can add some sugar or milk to taste. And that's it! You've got yourself a delicious cup of tea to enjoy.
"""


Answer:

Step 1 - Get some water boiling.
Step 2 - Grab a cup and put a tea bag in it.
Step 3 - Pour the hot water over the tea bag.
Step 4 - Let the tea steep for a few minutes.
Step 5 - Remove the tea bag.
Step 6 - Add sugar or milk to taste.
Step 7 - Enjoy your delicious cup of tea.
Prompt:
Your task is to answer in a consistent style.

<child>: Teach me about patience.

<grandparent>: The river that carves the deepest valley flows from a modest spring; the grandest symphony originates from a single note; the most intricate tapestry begins with a solitary thread.

<child>: Teach me about resilience.


Answer:
<grandparent>: Resilience is like the mighty oak that stands tall despite the storms it faces, bending but not breaking.
It is the ability to adapt, persevere, and bounce back stronger from challenges and setbacks.
Just as a seedling pushes through the earth to reach the sunlight, resilience allows us to grow and thrive even in difficult times.

Tactic 4: Specify the steps required to complete a task

Prompt:
Perform the following actions:
1 - Summarize the following text delimited by triple backticks with 1 sentence.
2 - Translate the summary into French.
3 - List each name in the French summary.
4 - Output a JSON object that contains the following keys: french_summary, num_names.

Separate your answers with line breaks.
"""In a charming village, siblings Jack and Jill set out on a quest to fetch water from a hilltop
well. As they climbed, singing joyfully, misfortune struck—Jack tripped on a stone and tumbled
down the hill, with Jill following suit. Though slightly battered, the pair returned home to
comforting embraces. Despite the mishap, their adventurous spirits remained undimmed, and they
continued exploring with delight."""


Answer:
1 - Siblings Jack and Jill embark on a joyful quest to fetch water from a hilltop well but encounter misfortune along the way, yet their adventurous spirits remain undimmed.
2 - Siblings Jack and Jill se lancent dans une quête joyeuse pour aller chercher de l'eau d'un puits au sommet d'une colline, mais rencontrent des malheurs en cours de route, cependant, leurs esprits d'aventure restent intacts.
3 - Jack, Jill
4 - {
"french_summary": "Siblings Jack and Jill se lancent dans une quête joyeuse pour aller chercher de l'eau d'un puits au sommet d'une colline, mais rencontrent des malheurs en cours de route, cependant, leurs esprits d'aventure restent intacts.",
"num_names": 2
}

Tactic 5: Iterative

Prompt 1:
Help a marketing team create a product description for a retail website based on a technical fact sheet.
Write a technical product description for furniture retailers using the information provided in the technical specifications. Focus on the materials used in construction and use a maximum of 50 words.

Prompt 2 (improved from prompt 1):
Help a marketing team create a product description for a retail website based on a technical fact sheet.
Write a technical product description for furniture retailers using the information provided in the technical specifications. Focus on the materials used in construction and use a maximum of 50 words.
Include every 7-character Product ID from the technical specifications.


Final prompt:
Help a marketing team create a product description for a retail website based on a technical fact sheet.
Write a technical product description for furniture retailers using the information provided in the technical specifications. Focus on the materials used in construction and use a maximum of 50 words.
Include every 7-character Product ID from the technical specifications.
After the description, create an HTML table titled "Product Dimensions" with two columns. The first column should list the dimension names, and the second column should list the measurements in inches only.
Format the description and table as HTML for website use, placing the description in a <div> element.

Technical specifications:
OVERVIEW
- Part of a beautiful family of mid-century inspired office furniture,
including filing cabinets, desks, bookcases, meeting tables, and more.
- Several options of shell color and base finishes.
- Available with plastic back and front upholstery (SWC-100)
or full upholstery (SWC-110) in 10 fabric and 6 leather options.
- Base finish options are: stainless steel, matte black,
gloss white, or chrome.
- Chair is available with or without armrests.
- Suitable for home or business settings.
- Qualified for contract use.

CONSTRUCTION
- 5-wheel plastic coated aluminum base.
- Pneumatic chair adjust for easy raise/lower action.

DIMENSIONS
- WIDTH 53 CM | 20.87"
- DEPTH 51 CM | 20.08"
- HEIGHT 80 CM | 31.50"
- SEAT HEIGHT 44 CM | 17.32"
- SEAT DEPTH 41 CM | 16.14"

OPTIONS
- Soft or hard-floor caster options.
- Two choices of seat foam densities:
medium (1.8 lb/ft3) or high (2.8 lb/ft3)
- Armless or 8 position PU armrests

MATERIALS
SHELL BASE GLIDER
- Cast Aluminum with modified nylon PA6/PA66 coating.
- Shell thickness: 10 mm.
SEAT
- HD36 foam

COUNTRY OF ORIGIN
- Italy
"""


Answer:
<div>
<h3>Product Description</h3>
<p>
Part of a beautiful family of mid-century inspired office furniture, this chair (Product ID: SWC-100, SWC-110) is constructed using high-quality materials. It offers various options for shell color and base finishes, along with upholstery choices in fabric or leather. With its versatile design, it is suitable for both home and business settings.
</p>
</div>
<table>
<caption>Product Dimensions</caption>
<tr>
<th>Dimension</th>
<th>Measurement (inches)</th>
</tr>
<tr>
<td>Width</td>
<td>20.87"</td>
</tr>
<tr>
<td>Depth</td>
<td>20.08"</td>
</tr>
<tr>
<td>Height</td>
<td>31.50"</td>
</tr>
<tr>
<td>Seat Height</td>
<td>17.32"</td>
</tr>
<tr>
<td>Seat Depth</td>
<td>16.14"</td>
</tr>
</table>
Note: The Product IDs from the technical specifications are SWC-100 and SWC-110.

Tactic 6: Summarising with a focus

Prompt:
Your task is to generate a short summary of a product review from an ecommerce site to give feedback to the Shipping department.
Summarize the review below, delimited by triple backticks, in at most 30 words, focusing on any aspects that mention shipping and delivery of the product.

"""Got this panda plush toy for my daughter's birthday, who loves it and takes it everywhere. It's soft and super cute, and its face has a friendly look. It's a bit small for what I paid though. I think there might be other options that are bigger for the same price.
It arrived a day earlier than expected, so I got to play with it myself before I gave it to her."""


Answer:
The product arrived a day earlier than expected, allowing the customer to play with it before giving it as a gift.

Tactic 7: Extracting

Prompt:
Your task is to extract relevant information from a product review from an ecommerce site to give feedback to the Shipping department.
From the review below, delimited by triple quotes, extract the information relevant to shipping and delivery. Limit to 30 words.

"""Got this panda plush toy for my daughter's birthday, who loves it and takes it everywhere. It's soft and super cute, and its face has a friendly look. It's a bit small for what I paid though.
I think there might be other options that are bigger for the same price. It arrived a day earlier than expected, so I got to play with it myself before I gave it to her."""


Answer:
The product arrived a day earlier than expected, allowing the customer to have time to play with it before giftin

Tactic 8: Identify sentiment

Prompt:
What is the sentiment of the following product review, which is delimited with triple backticks?
Give your answer as a single word, either "positive" or "negative".

"""Needed a nice lamp for my bedroom, and this one had additional storage and not too high of a price point.
Got it fast. The string to our lamp broke during the transit and the company happily sent over a new one.
Came within a few days as well. It was easy to put together.
I had a missing part, so I contacted their support and they very quickly got me the missing piece!
Lumina seems to me to be a great company that cares about their customers and products!!
"""


Answer:
Positive

Tactic 9: Extract data from text

Prompt:
Identify the following items from the review text:

Item purchased by reviewer
Company that made the item
The review is delimited with triple backticks. Format your response as a JSON object with "Item" and "Brand" as the keys.
If the information isn't present, use "unknown" as the value. Make your response as short as possible.

"""Needed a nice lamp for my bedroom, and this one had additional storage and not too high of a price point.
Got it fast. The string to our lamp broke during thetransit and the company happily sent over a new one.
Came within a few days as well. It was easy to put together. I had a missing part, so I contacted their
support and they very quickly got me the missing piece! Lumina seems to me to be a great company that cares
about their customers and products!!
"""


Answer:
{"Item": "lamp", "Brand": "Lumina"}

Tactic 10: Translation

Prompt:
Translate the following English text to Spanish:
"""Hi, I would like to order a blender"""


Answer:
"Hola, me gustaría ordenar una licuadora"

Tactic 11: Tone transformation

Prompt:
Translate the following from slang to a business letter:
"""This is Joe, check out this spec on this standing lamp."""


Answer:
Dear Sir/Madam,

I am writing to bring your attention to the specifications of the standing lamp provided by Joe. Please review the details enclosed.

Thank you for your attention to this matter.

Sincerely,
[Your Name]

Tactic 12: Classification

Prompt:
You were given a customer service query..
Classify each query into a category such as Billing, Technical Support, Account Management, or General Inquiry.

"""I want you to delete my profile and all of my user data"""


Answer:
{
"primary": "Account Management",
"secondary": "Profile deletion and data removal"
}

I hope you like the tactics above.

If you are new to ChatGPT/prompt engineering, I suggest having a look at this Getting Started with ChatGPT: A Beginner’s Guide to Prompt Engineering

--

--