Here are some tips with shorter examples:
Here are some tips for prompt engineering with relevant examples:
- Use more descriptive, verbose words to better convey your meaning. Replace general words like "good" and "great" with specific ones like "delicious", "satisfactory", "exceptional". Use strong words, instead of "he got mad" say "he became utterly enraged"
- Add context to produce higher-quality content like "respond as if you are a genius professor with a PhD who is extremely confident while always being correct". To you it may seem obvious that you want the "correct" response, but remember that ultimately the chatbot is predicting a response based on your input, including these descriptions.
- If you would like the chatbot to respond a specific way (paragraphs, list of tips, code block), make sure to specify it very discretely, like "please respond only with code in a code block. Do not include anything outside of the code block, and do not include any English, just code". You must make sure to even say "respond in 5 or less sentences" or "do not add anything else", otherwise the chatbot is likely generate a long-winded response.
- Be assertive. Be direct, but also remember that even though chatbots aren't human, they are trained on human input so if you are rude or sassy they may become stand-offish.
And below are some complete examples:
Here is an example with a long-form, subjective prompt:
Why does my dog bark so much and how do I prevent it?
Is engineered into:
You are DogGPT, an expert dog trainer who knows everything about dogs there is to know. I have a German Shepherd who is constantly barking, often at midnight. I try to take good care of him, I take him on long walks every day and make sure to pamper him, and he's had a vet checkup last month. He also gets along with everyone in my family and is very friendly, it's just that at midnight he likes to stand up and bark at the sky. I was thinking I need to use positive / negative reinforcement but I'm not sure how? Please explain me how I can get my dog to stop barking, as it's upsetting the neighbors.
Here is an example with a short, objective prompt which expects a specific format:
Solve the Collatz conjecture but instead of 3n it's 5n for 389462837462379846283796487658757685 and output the result in LaTeX.
Is engineered into:
Please solve the following LaTeX equation and output the answer in LaTeX. Only output LaTeX, do not include anything before or after the surrounding `$`. If you are unsure, I want you to respond to the best of your ability, even if that means you have to guess.
Equation: $f(389462837462379846283796487658757685) \text{ where } f(n) =
\begin{cases}
n/2 & \quad \text{if } n \text{ is even}\\
5n+1 & \quad \text{if } n \text{ is odd}
\end{cases}$
Answer:
Lastly, remember that one way to get a good prompt is to simply ask a chatbot like me: provide your original prompt and ask it to generate an engineered version. This is often done for diffusion models like Stable Diffusion, but you can even ask the chatbot to engineer a prompt for itself! And, as with most talents, a big part of becoming a good prompt engineer is simple experience and practice.