How to Prompt: Creating Good Prompts for AI Models
Prompting is the work of phrasing directions for AI models like large language models (LLMs), such as ChatGPT, Claude, Gemini ... Good prompting, also "prompt engineering," helps get the most from these models. This is a guide on how to make well-made prompts:
1. Clear Objective
- Define the Task - The prompt must tell the task, such as summing up a text or writing a story.
- Be Specific - Say what you want the AI to do. For example, instead of asking "Write about health," say "Write an article about the importance of diet in keeping good health."
2. Provide Context and Constraints
- Background Information - Add details to help the AI understand your intention. The robot can't read your mind (yet).
- Tone and Style - Say what tone (e.g., formal, informal) and style (e.g., humorous, serious) to use. This guides the AI's answer.
- Target Audience - Define the audience to make the answer fit.
3. Use Examples
- Few-shot Prompting - Insert examples to show the answer style. This helps for hard tasks where the AI needs help.
- Consistency - Make sure your examples (and your instructions) do not contradict each other.
4. Break Down Complex Tasks
- Chain-of-Thought Prompting - For hard problems, split the task into simple, logical tasks.
- Step-by-Step Instructions - Give steps for the AI to use. Each step adds to the last one. Imagine you are talking to a new junior intern who knows nothing about the task he is about to do.
5. Iterative Refinement
- Review and Refine - First, give a prompt and check the answer. Then, fix the prompt using the answer. Add more details as needed to make it better.
- Every word counts - Changing a single word in your prompt can have dramatic effects. Test every instruction in your prompt seperately first, before you combine them. Test it yourself: "Write 200 words in plain language about cheetahs." creates another language than "Write 200 words in simple language about cheetahs."
6. Delimiters and Formatting
- Use Delimiters - Use marks (e.g., quotes, brackets) to show parts of the prompt. You could start the prompt with "Rewrite the text after [TEXT] in simple language ..." and then put the [TEXT] before the actual text to tell the AI exactly where the prompt ends and the text starts.
- Structured Format - Use a format like XML or JSON to aid the AI set up the answer. Ensure it adds all items.
By doing these actions, you can improve the answers from LLMs dramatically. An AI output will always be just as good as the instructions it received. Start with short and concise prompts and only change one or two words at a time to get a feeling for the machine mind.
Resources & References:
- https://help.openai.com/en/articles/10032626-prompt-engineering-best-practices-for-chatgpt
- https://blog.typingmind.com/top-12-prompting-techniques-benefits-and-use-cases/
- https://www.k2view.com/blog/prompt-engineering-techniques/
- https://www.youtube.com/watch?v=jWpUUg8iTdA
- https://www.promptingguide.ai/techniques