• Skip to primary navigation
  • Skip to main content
  • Skip to footer
Jeremy Hixon

Jeremy Hixon

WordPress and Web Developer

  • Tools
  • About
  • Contact
  • Search
  • Login
  • Register

ChatGPT Prompt Engineering Notes

May 16, 2023 by Jeremy Hixon

Introduction

I’ll be attempting to keep this as language-agnostic as I possibly can. Text to be used in the prompts will be kept separate for clarity and will be referred to in the prompt itself simply as {text}. Either way, I’ll try to keep it as simple as possible.

Guidelines

Prompting Principles

  • Write clear and specific instructions
  • Give the model time to “think”

Principle 1: Write clear and specific instructions

Tactic 1: Use delimiters to clearly indicate distinct parts of the input
```Content```
"""Content"""
<Content>
<tag>Content</tag>

For example:

Prompt

Summarize the text delimited by triple backticks into a single sentence. ```{text}```
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.
Tactic 3: Ask the model 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."

"""{text}"""

Text (Passes):

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.

Text (Fails)

The sun is shining brightly today, and the birds are singing. It's a beautiful day to go for a walk in the park. The flowers are blooming, and the trees are swaying gently in the breeze. People are out and about, enjoying the lovely weather. Some are having picnics, while others are playing games or simply relaxing on the grass. It's a perfect day to spend time outdoors and appreciate the beauty of nature.
Tactic 4: “Few-shot” prompting

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.

Principle 2: Give the model time to “think”

Tactic 1: Specify the steps required to complete a task

Text

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.

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.

Text:
```{text}```

Note: Ask for output in a specified format.

Prompt

Your task is to perform the following actions: 
1 - Summarize the following text delimited by <> 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.

Use the following format:
Text: <text to summarize>
Summary: <summary>
Translation: <summary translation>
Names: <list of names in Italian summary>
Output JSON: <json with summary and num_names>

Text: <{text}>
Tactic 2: Instruct the model to work out its own solution before rushing to a conclusion

Prompt

Determine if the student's solution is correct or not.

Question:
I'm building a solar power installation and I need help working out the financials. 
- Land costs $100 / square foot
- I can buy solar panels for $250 / square foot
- I negotiated a contract for maintenance that will cost me a flat $100k per year, and an additional  $10 / square foot
What is the total cost for the first year of operations 
as a function of the number of square feet.

Student's Solution:
Let x be the size of the installation in square feet.
Costs:
1. Land cost: 100x
2. Solar panel cost: 250x
3. Maintenance cost: 100,000 + 100x
Total cost: 100x + 250x + 100,000 + 100x = 450x + 100,000

The AI will assume the student is correct because it just skims the content. We can fix this by instructing the model to work out its own solution first.

Prompt

Your task is to determine if the student's solution is correct or not.
To solve the problem do the following:
- First, work out your own solution to the problem. 
- Then compare your solution to the student's solution and evaluate if the student's solution is correct or not. 
Don't decide if the student's solution is correct until 
you have done the problem yourself.

Use the following format:
Question:
```
question here
```
Student's solution:
```
student's solution here
```
Actual solution:
```
steps to work out the solution and your solution here
```
Is the student's solution the same as actual solution just calculated:
```
yes or no
```
Student grade:
```
correct or incorrect
```

Question:
```
I'm building a solar power installation and I need help working out the financials. 
- Land costs $100 / square foot
- I can buy solar panels for $250 / square foot
- I negotiated a contract for maintenance that will cost me a flat $100k per year, and an additional $10 / square foot
What is the total cost for the first year of operations as a function of the number of square feet.
``` 
Student's solution:
```
Let x be the size of the installation in square feet.
Costs:
1. Land cost: 100x
2. Solar panel cost: 250x
3. Maintenance cost: 100,000 + 100x
Total cost: 100x + 250x + 100,000 + 100x = 450x + 100,000
```
Actual solution:

Model Limitations

Hallucinations

Boie is a real company, the product name is not real.

Prompt

Tell me about AeroGlide UltraSlim Smart Toothbrush by Boie

This prompt will “make up” a fairly realistic piece of content about a product that does not exist.

Reducing Hallucinations

Ask the AI to find relevant information first and then answer the question based on this relevant information.

Next: Iterative Prompt Development

Share this:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Reddit (Opens in new window) Reddit

Related

Pages: Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Page 8

Filed Under: AI Tagged With: ai, chatgpt, web development

Footer

About Me

Web Developer, nerd, car lover and fan of learning. More…

  • Facebook
  • GitHub
  • LinkedIn
  • Twitter

Search

Categories

© 2025 Jeremy Hixon

  • Client Hosting
  • Privacy Policy