Three ways to improve your prompting skills and prevent hallucinations
Writing prompts is a new task. With the launch and adoption of AI tools such as ChatGPT, we have been tasked with crafting highly specific and clear prompts. While a prompt like "write me a blog post about generative AI" is pretty straightforward, you can enhance the quality and usability of the AI output by adding more context to your prompts. In this discussion, I will focus on three aspects: providing examples, offering reasoning, and specifying the output format. Following these three guidelines will significantly boost your prompt engineering skills.
Why are well-built prompts so important?
A model like ChatGPT is trained on an enormous amount of diverse data, including scholarly articles and resources such as Wikipedia. Given its expansive knowledge base, generating an answer that perfectly aligns with your specific context can be challenging for the AI. Moreover, without clear guidance, ChatGPT can deviate from the truth and produce inaccurate responses—a scenario often referred to as 'hallucination.' What's more problematic is that the model doesn't typically express uncertainty about its answers. This underlines the importance of providing as much high-quality context as possible. Not only will this enhance the usability of the AI's output, but it will also prevent potential inaccuracies. Without this context, the AI can't fully comprehend what is expected. As a workaround, you can use a prompt like “Answer the question as truthfully as possible, and if you're unsure of the answer, say 'Sorry, I don't know’,” to encourage the AI to express uncertainty when appropriate.
1. How to Use Examples to Improve ChatGPT's Response
Utilizing well-crafted examples can significantly enhance the quality of the output that ChatGPT provides. This method, often referred to as "few-shot prompting" essentially involves teaching ChatGPT the type of output you desire. Providing 3 to 5 examples is recommended, but even one example can still improve the outcome. This technique is particularly effective when you want ChatGPT to adopt a specific tone of voice, text format, or thought pattern. The method is straightforward: simply instruct the model to "use these examples to complete your task", insert your examples, ask your question, and receive your output.
2. How to guide ChatGPT threw up a problem
Another method to give ChatGPT more context is by outlining the steps it needs to follow to complete your task. This approach, known as "Chain-of-thought prompting", allows you to steer ChatGPT towards accomplishing the task exactly as you desire. By specifying the necessary steps, you not only guide the AI towards an expected outcome, but also make the result more replicable. This method is particularly useful when you want ChatGPT to tackle more complex and detailed tasks such as crafting an action plan, writing code, or performing copywriting. Implementing this method is quite simple: just instruct ChatGPT about the steps it needs to follow. For example, say: "Step 1, Step 2, etc.," or let it apply a well-known model or theory to complete the task. You can even instruct it to use the "See, Think, Do" model to guide it towards the best outcome.
Example
Task: Now you will create 2 different quizzes about Formula 1.
Step 1. Each quiz has 5 multiple-choice questions, each with 3 possible answers.
Step 2. In terms of difficulty, build up the quiz so that questions 1 and 2 are easy, questions 3 and 4 are a bit more challenging, and question 5 is manageable for a Formula 1 connoisseur.
Step 3. Make sure there are no duplicate questions in any of the quizzes, so all questions are unique.
Step 4. For each quiz question, also indicate what the correct answer is.
Step 5. Each quiz has its own topic. Use the following topics for each quiz: quiz 1 is about the last 6 races of the current Formula 1 season. Quiz 2 is about fun facts of Formula 1.
Step 6. Lastly, write everything in English.
Step 7. Can you also give a fun explanation for each correct answer in one sentence?
3. Guiding the output of ChatGPT
This simple step can greatly enhance the usability of ChatGPT's output. While the AI is often surprisingly adept at guessing your desired output, guiding it to align with your work style and preferred format can be beneficial. Personally, I find it helpful to have ChatGPT organize information into tables. This can be easily accomplished by saying, "can you put it in a table". You can then modify the table by asking it to "add a new column with suggested titles". Although it doesn’t always adhere to these instructions, you can still provide guidelines on the length of its output. For instance, you might request it to "make it shorter, be more detailed, or can you shorten it". It may be slightly frustrating that you can't specify a word count for the output, but these tips can still help in shaping the final result.
These methods alone can really improve your output. But to improve your output even more you can start combining these methods and your own methods to make your prompts as good as possible.
Good luck!