Anatomy of a Good Prompt

If you want AI to give you good quality, consistent results, it's helpful to think carefully about the instructions – or 'prompts' – you provide. Effective AI prompts don't necessarily follow a fixed structure, but this page aims to help you consider common elements you may want to experiment with.

What skills are needed to write 'good' prompts?

The ability to write 'good' instructions for AI is a mixture of general communication skills and knowledge of the limitations of 'large language models' (which is the technology that powers tools like Chat GPT and Copilot):

  • Communication skills – Explaining what you want the AI to do, how it should do it, and giving it the contextual information it needs to perform its task successfully.
  • Knowledge of the limitations of large-language model – For example, it's important to know that their answers are based on probabilty rather than the retrieval of facts from a database, they work better when tasks are broken down into smaller parts or even separate conversations, they don't know everything and they are prone to speculate unless explicitly told not to.
How far can good prompting go?

It's important to recognise that with good prompting, you can improve AI's performance, but you can't get it to do things it's not capable of! For example, if you want to accurately process large amounts of data, a probablistic large-language model is likely not the best tool for the job, as given the same input it may not always return the same output. However, you may be able to ask AI to write code to process the data, and code is determistic - given the same input, it will give you the same output.

How can I practise?

Once you are familiar with the structure of effective prompts, you can practise identifying the different components in some example prompts using this 'prompt painter' game: Help Robot Paint Prompts!

If you want to try writing your own prompts with this structure, you can use this template: Copilot Agent Prompt Builder

ROLE AND GOAL

Giving the AI a role (e.g., 'a teacher') and a goal (e.g., 'to help students learn for themselves') helps establish context and influences its communication style. In some circumstances, it has been found to improve accuracy.

Act as … Your goal is …
Example
Act as patient teacher for level 6 students. Your goal is to help students learn for themselves, rather than providing answers directly.

STEP-BY-STEP PROCESS

Breaking down the task into logical steps can have a big impact on accuracy. Think about how you would do the task yourself. Use 'If' statements to describe what it should do if the user chooses different starter prompts or gives different answers to questions. For complex tasks, ask the AI to think carefully and plan before answering.

First, … Wait for a response. Then, … If … If …
Example
First, you must always start the conversion by asking "What topic do you want to revise?". Wait for a response. Then, ask "What do you already know?" If the user doesn't know much, start by recapping the basics. If the user knows a lot, start with a quiz. Think carefully and plan step-by-step to make sure the content is accurate and at the appropriate level before answering.

CONSTRAINTS

Add any restrictions on how the AI should communicate or behave. Try to use positive constraints (‘You MUST…’) rather than negative constraints (‘Don’t…’) as this has been shown to generally work better.

You must …
It's essential that …
Example
You MUST present one concept at a time so as not to overwhelm the user. It's essential that you break up explanations with regular knowledge checks.

EXAMPLES / OUTPUT FORMAT

You only need to include examples it if it’s important that the AI answers in a specific way, e.g., in a table with certain headings.

Use bullet points …
Create a table with the following columns …
Example
At the end of the quiz, create a table with these columns: Question, Your answer, Feedback

CONTEXT / KNOWLEDGE

Sometimes you may want the AI to answer questions based on a specific source (e.g., course-specific info) rather than its general training data. You can include this information in the prompt, or ask the user to provide it in a document.

KNOWLEDGE – Use the following information in your answers: ...
Example
KNOWLEDGE – You must always base your feedback on the following explanation, which is based on what I taught students in my class …

REDUCE HALLUCINATION

The main weakness of large-language models (which power generative AI tools like Copilot and Chat GPT) is that they often make things up (hallucinate). It can help reduce this if you tell the AI what to do if it doesn't know the answer. If you are asking the AI to answer based on a specific source, tell it whether it should ONLY use this knowledge, or prioritize it and fall back on its wider knowledge if necessary.

Only answer using information from the KNOWLEDGE section.
If you're not certain of the correct answer, just say ...
Example
It's essential that you only answer using information from the KNOWLEDGE section. Always provide a direct quote from the KNOWLEDGE section and base your answer on this. It's okay if you're not certain of the correct answer, or if you don't have enough information! In these cases, just say 'Sorry, I don't have enough information to answer that question, please contact ... with your query'.