How to write a good ChatGPT Prompt: 7 key tips
Prompts, or instructions, play a fundamental role in how artificial intelligence models such as ChatGPT generate their answers.
A prompt is the information we give the model to guide it towards generating the answers we want.
If you want to use artificial intelligence successfully to improve your work, you will need to write effective prompts. In this article we explain how to write an effective prompt for ChatGPT (and for any generative AI model in general) that gets you quality results that add value.
What is a prompt?
An artificial intelligence instruction, also known as a prompt, is a piece of text written in natural language (in English, for example) that is sent to an Artificial Intelligence service (ChatGPT, for example) to obtain an answer or completion.
1. The difference between context and query
A prompt has two main components: the context and the query. The most common mistake inexperienced people make when writing prompts is asking questions without context.
The context provides any relevant information ChatGPT needs in order to understand the setting in which it should consider your question.
The query, on the other hand, should explain exactly what you want ChatGPT to answer.
Here are three examples of prompts with the context and the task/query separated. Normally you would put it all in the same sentence, or separated by a full stop — the order does not matter — but in this article we set them out separately so you can see the difference:
Example 1:
Context: Photosynthesis is a fundamental process in plants. Through photosynthesis, plants use the sun’s energy to convert carbon dioxide and water into glucose and oxygen.
Task/Query: Explain in accessible language for a young audience how photosynthesis works in plants, in about 400 words.
Example 2:
Context: Climate change is a global problem affecting our planet. Rising greenhouse gas emissions are causing global warming.
Task/Query: Describe the effects of climate change on the environment and how we can mitigate its impacts. Cite scientific publications and studies and use technical language. I want a text of about 600 words.
Example 3:
Context: The Industrial Revolution was a historical period of significant change in production, technology and society.
Task/Query: Explain how the Industrial Revolution changed the way people worked and lived, and mention some important inventions from that period.
As you can see, the context provides relevant information and background on the subject, while the task or query is the specific instruction given to ChatGPT to generate an answer or carry out a particular task.
It may look redundant, but context helps the AI a great deal. Keep experimenting with it and you will see how the quality of what you get improves.
2. Be clear and specific about what the answer should look like
Give precise details in your question to guide the model towards the answer you want. The more information you provide, the fewer assumptions the model has to make.
For example, instead of simply saying “Classify this post“, it is more effective to specify the objective, such as “Classify the sentiment of this message as positive, neutral or negative: ‘My puppy is adorable❤️❤️'”. That way the model clearly understands the task and can generate a more precise answer, in this case: “positive”.
You can specify many more details about the answer, including the format. Use the following tricks to get the answer you want:
- “Be concise, keep prose to a minimum”
- “Use little corporate jargon”
- “Return the answer as separate bullet points with short sentences”
- “Return your answer in a table with columns X, Y, Z”
- “Be extremely detailed”
- “Return your answer in JSON format following this example []” (this lets you process the answer automatically)
3. “Few Shot Learning”: provide examples of results
Few-shot learning is a useful technique for guiding the AI model with specific examples.
As part of your prompt, you can include examples of results similar to the ones you want. This will help the model generate more suitable answers. For example: “I am going to give you a series of objects, and I want you to tell me whether they are small, medium or large. As an example, I consider a car medium, a bicycle small, and anything as big as an elephant or bigger, large. Here is the data: Rocket, house, flea, football, dog, chair, city”
Providing examples of results and explaining what kind of answer is valid is necessary if you intend to process ChatGPT’s answer automatically.
In that case, you will need its answer to be a number or a specific word. You have to provide that information in the prompt. For example:
“Given this issue that a user has sent to my IT support service, I want you to reply only with a number from one to 10, where 1 would be a very non-urgent query and 10 would be an extremely urgent one. I consider urgent any issue that stops users getting on with their work. I consider non-urgent those that, while a problem, still allow work to continue. Here is the issue: MY COMPUTER WON’T TURN ON”
In this case you would almost certainly get a 10 as the answer.
Technical tip: you can ask ChatGPT to give you answers in any language and format (JSON, for example), which lets you process the answers automatically.
4. “Grounding”: prioritise the sources you want the AI to use
AI models have been trained on a huge amount of information from the internet, and some of them even have a real-time connection to it. Since the internet contains everything, and although it has been designed to try not to, ChatGPT could produce an answer that gives weight to knowledge of any kind: popular science, scientific, humorous, or simply picking a position at random on a controversial subject.
Providing context and prioritising sources in your prompts will avoid incorrect or fictitious answers
If you want the answer to a prompt to give more weight to one type of knowledge than another, you have to tell the model which sources, facts, authorities or references you consider valid. This technique is called “Grounding”, since you are grounding the model’s answer in things you consider to be true.
For example, if you say: “Galileo showed that the planets revolved around the sun in the early 17th century. The planets follow elliptical orbits. Give a simple explanation for an audience of 12-year-olds about what the orbits of the solar system are like”.
You are making sure ChatGPT is not going to use any kind of rumour or alternative theory in its explanation of heliocentrism.
Providing specific data and important facts about the subject, and citing sources or authorities you consider appropriate, will help the model generate a more accurate answer that you value more highly — which is, after all, the goal.
5. Temperature: adjust the creativity of the answer
When you send a prompt to ChatGPT you can tell it to use a temperature of X, where X is a decimal number between 0 and 1 (for example: “[…] use a temperature of 0.3 for your answer”). The “temperature” parameter controls the randomness of the answers the model generates, making them more “daring” (higher temperature, closer to 1) or more “measured” (lower temperature, closer to 0).
Temperature is used to adjust how creative the answer is.
When a low temperature is set (0.1, for example), the model is more conservative and produces more coherent, predictable answers, choosing the most probable words. This can be useful when you want more precise, less ambiguous results.
When you raise the temperature (1.0, for example), on the other hand, the model becomes more creative and generates more varied, surprising answers. In this case the model has more freedom to explore different words and produce more original — and sometimes less coherent — answers.
For example, we could tell ChatGPT: “Write a story in which a group of friends have adventures on a pirate ship in the Caribbean seas. Use a temperature of 0.7 for your answer.”
Temperature therefore acts as a kind of “creativity dial” that lets you adjust the balance between coherence and variety in the answers generated. Bear in mind that, as you raise the temperature, the likelihood of generating answers that are incoherent or barely related to the context of the conversation also increases.
6. Writing style: set the tone of the results
You can ask ChatGPT to generate an answer in a particular writing style (for example “[…] use a persuasive tone for your answer”). If you also combine the writing style with the temperature, you can get results closely matched to what you need. Here are some examples:
- Formal:
- Low temperature (0.1): “Thank you for your enquiry; I am pleased to provide the information requested. According to the data collected, the expected result is as follows: [precise answer].”
- High temperature (1.0): “Warm regards. We have diligently reviewed your query and the results obtained are as follows: [more detailed and formal answer].”
- Informal:
- Low temperature (0.1): “Hey, here’s what you need: [short, simple answer].”
- High temperature (1.0): “Hey! Don’t worry, I’ll tell you everything! [more relaxed, conversational answer].”
- Persuasive:
- Low temperature (0.1): “Based on thorough studies, I strongly recommend you consider the option I am presenting. Its benefits are notable and you could see significant improvements.”
- High temperature (1.0): “Come on, I promise you this option is brilliant! You won’t regret it, I guarantee it! Just imagine all the benefits you’ll get.”
- Descriptive:
- Low temperature (0.1): “The scene unfolds in a wide green meadow, with vividly coloured flowers dancing in the wind. The sun’s rays light up the landscape, creating a warm, welcoming atmosphere.”
- High temperature (1.0): “The setting is astonishing! You will be transported to a magical meadow, full of flowers bowing as though they were dancing. The sun’s rays light everything with dazzling energy. It is a scene that will take your breath away!”
- Humorous:
- Low temperature (0.1): “Why don’t birds use Facebook? Because they already have Twitter! Ready for the answer? [answer with a touch of humour].”
- High temperature (1.0): “What do bees do at the gym? Zum-ba! Ha ha! Let me tell you more: [answer with a funnier tone and extra jokes].”
- Narrative:
- Low temperature (0.1): “The sun peeked shyly between the mountains, painting the sky in golden tones. The birds sang cheerfully while the wind whispered through the trees. At that moment, something unexpected happened…”
- High temperature (1.0): “The morning dawned spectacularly, the sun shone fiercely and the mountains seemed to come alive. The birds, full of enthusiasm, sang in harmony while the wind played with the leaves. And suddenly, something nobody expected happened…”
- Inspirational:
- Low temperature (0.1): “However dark the road, there will always be a light at the end of the tunnel. Perseverance and determination are key to overcoming any challenge. You can do it!”
- High temperature (1.0): “Don’t give up, ever! Remember that inside you there is a powerful force driving you to reach your dreams. Whenever you fall, get up stronger and keep going. You are capable of great things!”
- Confrontational:
- Low temperature (0.1): “Unfortunately, your arguments lack foundation and do not fit the facts. I suggest you reconsider your position and review the information provided earlier.”
- High temperature (1.0): “You seriously believe that? Well, you are very much mistaken! Let me show you the reality and leave you speechless. Pay attention to this…”
7. “Role Playing”: start a story and have ChatGPT continue it.
One of the most effective techniques for giving a prompt context and quality and fine-tuning the accuracy of the answer is “Role Playing”, that is, playing a part or character. It means using prompts along these lines:
“You are a customer service agent at a medium-sized appliance repair company in Madrid. Your customers are people who have had a problem with their washing machine, dishwasher or fridge and are calling you for help. One of them has just filled in a form and says this: THE WASHING MACHINE ISN’T RINSING PROPERLY. Write a descriptive reply of 800 words with a proposed solution to the problem, with temperature 0.8”
In the prompt, we have ChatGPT take on the role of a specific character in a “story”. Instead of presenting a direct query or request, we simulate a script or a conversation with a fictional character, allowing the model to respond accordingly.
This technique is useful for several reasons. First, it can help you get more contextualised, coherent answers, since you are giving the model a clear frame of reference.
By setting a scenario and defining the roles, ChatGPT can adjust its answers according to the personality or perspective of the character you ask it to play.
Role-playing can also be a creative tool for exploring different points of view. You can simulate a conversation with an angry customer, an expert one or a complete novice. That lets you get imaginative answers and see how the model interprets and responds from that particular perspective.
How to use a prompt to automate your daily work
Generating results through prompts is a process of trial and error. Do not be discouraged if you do not get the results you expected straight away. Experiment with different approaches and techniques, and use the initial results generated by the model as a basis for refining and improving your prompts.
A good prompt with a high success rate for a task that is useful to you is a treasure.
Imagine you have arrived at a prompt that can solve one of the office tasks you carry out every day (writing a reply to an email, classifying a text, extracting data from a paragraph and so on).
From that moment on you can use ChatGPT for your work but, instead of having to copy and paste texts into your browser, you can use Process Management software such as Docuo to automate the use of that prompt.
You will be able to extract information from work documents, answer your customers’ questionnaires or detect data in business texts automatically, inside the application.
If you would like us to show you how to use your prompt to automate your work, do not hesitate to get in touch to see a demo.