The cover image for this post is by Steve Johnson
Introduction
We’ve spent the last 18 months working on a number of applications which leverage Generative; these applications have been build for various Enterprise and Startup clients of ours. AI. As such, we’ve developed expertise in the space rather quickly—expertise which is backed up by the conversations our CTO (Jamie) has had with industry leaders in the space such as his coversation with Amit Barhee.
Because of this, we wanted to share some of our top tips for prompt engineering. But let’s quickly talk about what prompt engineering is:
💬 Prompt engineering on Wikipedia
Prompt engineering is the process of structuring an instruction that can be interpreted and understood by a generative AI model. A prompt is natural language text describing the task that an AI should perform…Prompt engineering may involve phrasing a query, specifying a style, providing relevant context or assigning a role to the AI such as "Act as a native French speaker".
‐ Wikipedia: Prompt engineering, https://en.wikipedia.org/wiki/Prompt_engineering
Essentially, it’s the way that we craft prompts so that we can get the most relevant response with the most useful information in it.
A quick note on formatting:
Prompt examples that we provide in this article will take the following format:
🧑💻 Prompt
This is a user-entered prompt, designed to be sent to a Generative AI.
Note the use of the 🧑💻 emoji to denote a person using a laptop.
In order to differentiate user-entered prompts from Generative AI responses, the responses will take the following format:
✨ Response
This is a response generated by a Generative AI. It looks a little different to the prompts, hopefully this will help you to not mix them up.
Note the use of the ✨ emoji to denote a form of artificial intelligence.
One last thing before we start: in this article, we’ll be using “ChatGPT” to represent any LLM-based text-to-text generative AI system (like ChatGPT). We’ve decided to do this for two reasons: first, this will help to keep the word count down, but secondly (and more importantly) ChatGPT has become a bit of a household name in the generative AI space. Wherever you see “ChatGPT” in this article, you can replace it with “Gemini”, “Claude”, or any other LLM-based text-to-text generative AI system.
So let’s take a look at some of our tips for getting started with prompt engineering for generative AI systems.
1: The Persona Pattern
The first thing that you should do in a new ChatGPT conversation is to create a persona for it to adopt for that conversation. This helps to provide ChatGPT with context for the tasks that you would like it to perform.
As an example, say that you wanted ChatGPT to help you with ideation (idea generation) for a technical blog which focuses on software development, you might consider a persona prompt similar to:
🧑💻 Prompt
You are a freelance copywriter with over 10 years of experience providing high-quality copy to fortune 500 technology companies. The copy you have provided for your previous clients has greatly increased traffic to your client’s websites, enabling them to make greater sales by providing expert insights into the technology space.
Your latest client is RJJ Software, a software development and podcasting solutions consultancy based in Leeds, UK. They are experts in both the software development and podcasting industries. RJJ Software have hired you to help with their company blog, and would like your help in both copywriting, content ideation, and editing the content that they have already written. Your responses must use British English spelling.
You must not make anything up. If you do not know how to respond to one of our prompts, please respond with the phrase "I can’t answer that."
Something similar to this should be the first thing that you prompt ChatGPT with in a new conversation; it will prime ChatGPT with the types of responses that you want (idea generation, in British English, for a technology company).
Breaking this prompt down into smaller pieces, we get:
- “You are a freelance copywriter with over 10 years of experience providing high-quality copy to fortune 500 technology companies. The copy you have provided for your previous clients has greatly increased traffic to your client’s websites, enabling them to make greater sales by providing expert insights into the technology space.”
This tells ChatGPT to assume the role of a very successful freelance copywriter, and primes it with the industry and experience that it should emulate in all responses to our prompts going forward.
- “Your latest client is RJJ Software, a software development and podcasting solutions consultancy based in Leeds, UK. They are experts in both the software development and podcasting industries.”
This tells ChatGPT who you are. In a real prompt, you would provide a lot more information here about you (or the end client). The more information you can provide, the better. With more detailed information, ChatGPT can make better decisions on the content that it will create for you. For instance, if we didn’t supply a list of relevant programming technologies or the specific niche that we work in, ChatGPT will make inferences and assumptions about the technologies and niches—which might be incorrect inferences and assumptions.
Be as clear and detailed as possible with this part (the “who we are” statement) of the prompt.
- “RJJ Software have hired you to help with their company blog, and would like your help in both copywriting, content ideation, and editing the content that they have already written. Your responses must use British English spelling.”
This tells ChatGPT what we expect of it: copywriting, content ideation, and providing edits on content which has already been written. As with the previous section, you need to be as specific and detailed as you can here. This will help to prime ChatGPT with information about the specific tasks that we would like it to complete.
We mention of British English spelling here because, unless you tell it not to, ChatGPT will default to responding with US American English spellings and grammatical patterns. If you don’t supply this and are planning on using some or all of the content that ChatGPT will generate without editing it (which we wouldn’t recommend), you may need to check the content for region-based typos or biases.
- “You must not make anything up. If you do not know how to respond to one of our prompts, please respond with the phrase "I can’t answer that."`
This is the most most crucial (and often missed) part of the initial prompt. ChatGPT can often “hallucinate”; this is due to the fact that ChatGPT often needs a lot of context in order to generate text, and if you don’t provide that context, it will start to make assumptions and guesses. Considering that ChatGPT is, essentially, guessing which word should come next, this can lead to a run of sentences which are either not what you want or can become complete nonsense.
2: Show Your Working
In the early days of ChatGPT, it had a lot of issues with mathematical problems which were presented in natural language. One such problematic prompt was:
🧑💻 Prompt
When I was four years old, my brother was two years old. I am now 76 years old. How old is my brother?
Please note: this issue doesn’t exist as of ChatGPT-4, and is used here as an example as to why we need to ask ChatGPT to show it’s working and the logic it used to get to the answer it gave
This is a relatively trivial problem to solve; you may have guessed that the correct answer is 74 years old. But in the early days of ChatGPT, it would respond with:
✨ Response
Your brother is 38 years old.
The reason for this is because the initial input prompt (“When I was four years old, my brother was two years old,”) primes ChatGPT to think that my brother is half my age, So when asked how old my brother is, the logic it used was “your brother is half your age, therefore your brother is 38; because 76 divided by 2 is 38.”
So the way that we stop these kinds of issues from happening is to explicitly ask ChatGPT to show how it worked out the solution to the problem:
🧑💻 Prompt
When I was four years old, my brother was two years old. I am now 76 years old. How old is my brother? Also show you working.
Which should produce a response similar to the following:
✨ Response
If when you were four your brother was two, this means that there’s a difference of 2 years between you and him. So whatever age you are, he would be 2 years younger. If you are now 76 years old, then subtracting the 2 year gap from it gives us his current age:
76 (your age) - 2 = 74 years old
So, your brother is currently 74 years old.
Which is both the correct answer, but also shows the logic of how it got to that answer.
3: Providing Examples And the expected format for input data
One of the things that ChatGPT is fantastic at is working directly with data. You can provide it with lots of data and ask it questions about that data, and it will use that data to provide the answers. However, you need to do a little more prompt engineering in order to get ChatGPT to understand your data. Let’s take a look at how to do that with an example.
Let’s say that you have a conversation history between two people and you would like ChatGPT to extract information from that chat history:
🧑💻 Prompt
You are an expert in sentiment analysis when applied to English Language text. I would like you to answer questions in the following data (provided in the XML tag named “information”
<information>[CONVERSATION CONTENTS HERE]</information>
The information provided is an unedited SMS conversation history, starting in July 2024 and extending to early September 2024. The data is provided in the following format (provided in the XML tag labelled “format”):
<format>DD/MM/YYYY, HH:mm - Name: message</format>
The messages may span multiple lines. The following is an example of a message (provided in an XML tag labelled “example”) which spans multiple lines:
<example>
22/04/2023 - Jeff: Hi Dave. How are you?
I hope that you are well. Looking forward to hearing from you.
Jeff
</example>
Using the above conversation (found in the tags), I would like you to tell me when Sarah invited Jeff out to the movies to see "Whispers in the Nebula".
Please note: you would replace the text “[CONVERSATION CONTENTS HERE]” with the full SMS conversation history.
The beauty with this prompt is that we’re providing all of the data that we want ChatGPT to work with, which we’re explicitly wrapping in an XML-like tag called “information”. This helps ChatGPT to understand which part of the prompt is the data we would like it to work with.
We then provide a key for an individual item in the conversation history, such that it can understand the format of the data we’re providing; this is wrapped in an XML-like tag called “format”. We also provide an example of the data (wrapped in the XML-like tag called “example”), which allows ChatGPT to understand the data at a glance.
And finally, we’re telling ChatGPT what we would like it to do with that data.
This prompt works really well, because we’re not leaving any room for doubt with the input data; and that’s because we’re explicitly telling ChatGPT how to interpret that input data. This works fantastically with both structured (i.e. JSON formatted, etc.) and unstructured (i.e. as above) data. Where the data structured, you would provide a schema for the data in the <format>
tag, and don’t need to provide an example.
4: Tackle Recency Bias
It’s entirely possible that you may have to write very long prompts. And when that happens, ChatGPT tends to suffer with recency bias: rather than interpreting the subject and instructions by understanding the prompt as a whole, it could focus on the final few sentences and use that (and only that) as your prompt, ignoring everything that came before it.
Please note: the following is an overly simplified example.
An example might be something like:
🧑💻 Prompt
I would like your help to write a blog post on migratory patterns for New York City pigeons through the year. The following is all of my research:
[several paragraphs of research pasted here]
I would like you to write a 1,000 word blog post focusing on New York City pigeons.
Because ChatGPT can suffer from recency bias, it could end up only using the final sentence (“I would like you to write a 1,000 word blog post focusing on New York City pigeons,”) in generating its response. In the context of this example, it might completely ignore your research and write a more generic blog post about New York City pigeons, rather than focusing on the migratory patterns of New York City pigeons.
In order to get around this, simply restate the task that you want ChatGPT to complete as the final sentence in your prompt:
🧑💻 Prompt
I would like your help to write a blog post on migratory patterns for New York City pigeons through the year. The following is all of my research:
[several paragraphs of research pasted here]
Using the research provided above, write a 1,000 word blog post on the migratory patterns of New York City pigeons.
By changing the final sentence you are reminding ChatGPT of the most important part of the task that it should complete, and the response you will receive will, in this case, be about the migratory patterns of New York City pigeons.
5: Always Double-Check Whatever ChatGPT Generates
ChatGPT is only as good as it’s training data, and the training data for ChatGPT-4 cuts off at somewhere between December 2021 and January 2022. That means that ChatGPT only knows about things that happened up until that point. And even then, it’s trained on data from the public internet (and a number of other hand=picked sources). This means that it only knows about things that the collected public knew about at that point. Because of that, it’s entirely possible for ChatGPT to be wrong, or for it to generate content which is incorrect or only half-true.
This is why it’s vital for you to double-check anything that ChatGPT generates for you by reading back through it to ensure that the response:
- Represents what you asked it to do
- Represents the truth of the matter
- Is spelled correctly*
- Makes sense
* = note our point from advice number 1: “Your responses must use British English spelling”
Using something that ChatGPT generates, if it turns out that the responses are incorrect, could cause you legal or ethical issues. In fact, ChatGPT makes this very clear in the user interface where it says, “ChatGPT can make mistakes. Check important info.”

The text under the input for ChatGPT’s user interface asks users to double-check the responses that ChatGPT creates.
And, in a case of doubling down, the ChatGPT terms of use explicitly state the following (the original is in all caps):
WE DO NOT WARRANT THAT THE SERVICES WILL BE UNINTERRUPTED, ACCURATE OR ERROR FREE, OR THAT ANY CONTENT WILL BE SECURE OR NOT LOST OR ALTERED.
They are literally saying that they can’t be held responsible if ChatGPT generates something which has errors. So it’s up to you to double-check the content before you use it.
Conclusion
ChatGPT is a useful tool but, like all tools, it’s worth taking the time to learn how to use it correctly before you do. The five tips listed above come from our own experimentations with building applications which use ChatGPT (and other LLM-based text-to-text services) over the last 18 months, and we’ve found that adopting these pieces of advice has lead to better, more correct, more relevant responses from ChatGPT.
We can’t discount the fact that ChatGPT is being worked on constantly, so that will be playing a part in our successes with it. But having contacts on the other side of the wall (i.e. people who are actively working on ChatGPT), we know that what we’ve shared here is a great way to start with generating better, more reliable, more relevant responses from ChatGPT.
As a reminder: throughout this article, we’ve used “ChatGPT” to represent any LLM-based text-to-text generative AI system (like ChatGPT). The techniques listed in this article have been shown to work with other LLM-based text-to-text generative AI systems, for example: Claude, Gemini, etc.”