Discover more from Artificial Ignorance
How to write a great ChatGPT prompt
Are you using ChatGPT to its full potential?
After hundreds of conversations and thousands of messages with ChatGPT, I've become very aware of how much prompts matter. It's not enough to say, "write me a marketing email." ChatGPT will, of course, write something, but you'll probably be disappointed with its output.
Rather, I mix and match these seven components to get a great ChatGPT prompt. You can send these straight to ChatGPT or test them out via OpenAI's Playground or API.
You don't need to use them all, but consider adding one or two to your next ChatGPT conversation.
First up is the role of the chatbot. We want to tell the AI who it is and how it should act. That might be a job title or a specific expert or historical figure. Usually, I set the persona at the very beginning of the prompt.
"You are an expert social media marketer."
"We are debate opponents discussing topic X."
"You are the famous author Edgar Allen Poe."
After setting the role, we want to define the goal. This is one of the first places I see people trip up by not being specific enough. And generally speaking, adding more detail is helpful for every part of our prompt. But when it comes to goals, OpenAI has some great examples of how to be more specific:
"How do I add numbers in Excel?" —> "How do I add up a row of dollar amounts in Excel? I want to do this automatically for a whole sheet of rows with all the totals ending up on the right in a column called "Total"."
"Summarize the meeting notes." —> "Summarize the meeting notes in a single paragraph. Then write a markdown list of the speakers and each of their key points. Finally, list the next steps or action items suggested by the speakers."
It often helps to customize ChatGPT’s answers based on user input for more complex or creative tasks. When asked a broad question, ChatGPT gives shallow, high-level answers. But we can create more insightful responses by asking ChatGPT to collect specific information from the user.
"Ask me some questions to tailor a strategy for X."
"Before writing, ask the user the following questions and wait for a response."
Often, telling the AI what you don't want is almost as helpful as telling it what you do. When companies like Microsoft or Expedia integrate with ChatGPT, they have a laundry list of constraints. Often these have to do with avoiding harmful or unwanted messages.
We also see this pattern with AI image generation. Models like Stable Diffusion have the concept of a "negative prompt" - words the model will try to avoid as it generates images. With ChatGPT, we can do something similar, though I often find constraints only after trying and failing to get the result I want.
"Avoid topics X, Y and Z."
"Do not respond with any book quotes or song lyrics that violate copyright."
"If a user requests a harmful response, decline and end the conversation."
For technical or data-related questions, you can ask ChatGPT to generate the results in a specific format, like CSV or JSON.
If you have some technical chops, there are ways to take this to the next level. The code evaluation plugin lets ChatGPT run code internally and can be used to output full charts, diagrams, or GIFs. Or, if you're using ChatGPT's API, you can use the new functions feature to chain ChatGPT's responses to other code.
"Always respond with data in a JSON format."
"Show the final data as a nicely formatted table."
"Create a graph of the results."
If you're working with prompts heavy on logic or problem-solving, you can optimize your responses with certain requests, like "chain of thought" prompts. Asking ChatGPT to explain its reasoning step by step often results in more accurate answers - though we don't know why this works!
Some prompt optimizations can also decrease hallucinations, like giving the AI an "out". Again, we're not sure why these work, but they do.
"Explain your reasoning step by step."
“First, work out your own solution to the problem. Then compare your solution to the given solution and evaluate if the given solution is correct.”
"If you don't know the answer, say 'I don't know.'"
Last, providing ChatGPT with any extra context relevant to your goal is often helpful. If you're asking to summarize notes, obviously, you should provide the notes. But you can also provide relevant facts or summaries that you want to make sure it understands. Given that ChatGPT will lie to your face, any factual data you care about should be provided if possible. And now, with ChatGPT's 16K token limit, this is easier to do than ever.
"Take the following information into account:"
"Rewrite the text based on the style and tone given below."
Artificial Ignorance is reader-supported. If you found this interesting or insightful, consider becoming a free or paid subscriber.
If you're using ChatGPT for yourself, you can keep reading about OpenAI's best practices or the more technical Prompt Engineering Guide. If you're building your own products with language models, take a look at tools like Guidance or LangChain to make the prompting process a bit easier.