GPT can tell bad jokes and write accidentally hilarious poems about your life, but it can also help you do your job better. The catch: you need to help it do its job better, too.
At its most basic level, OpenAI's GPT-3 and GPT-4 predict text based on an input called a prompt. But to get the best results, you need to write a clear prompt with ample context. After tinkering with it for more hours than I'd like to admit, these are my tips for writing an effective GPT-3 or GPT-4 prompt.
Test your prompt
There's very little chance that the first time you put your AI prompt in, it'll spit out exactly what you're looking for. You need to write, test, refine, test, and so on, until you consistently get an outcome you're happy with. I recommend testing your prompt in the OpenAI playground or with Zapier's OpenAI integration.
GPT vs. ChatGPT. GPT-3 and GPT-4 aren't the same as ChatGPT. ChatGPT, the conversation bot that you've been hanging out with on Friday nights, has more instructions built in from OpenAI. GPT-3 and GPT-4, on the other hand, are a more raw AI that can take instructions more openly from users. The tips here are for GPT-3 and GPT-4—but they can apply to your ChatGPT prompts, too.
As you're testing, you'll see a bunch of variables—things like model, temperature, maximum length, stop sequences, and more. It can be a lot to get the hang of, so to get started, I suggest playing with just two of them.
Temperature allows you to control how creative you want the AI to be (on a scale of 0 to 1). A lower score makes the bot less creative and more likely to say the same thing given the same prompt. A higher score gives the bot more flexibility and will cause it to write different responses each time you try the same prompt. The default of 0.7 is pretty good for most use cases.
Maximum length is a control of how long the combined prompt and response can be. If you notice the AI is stopping its response mid-sentence, it's likely because you've hit your max length, so increase it a bit and test again.
GPT prompt guide: 8 tips for writing the best GPT-3 or GPT-4 prompt
Help the bot help you. If you do each of the things listed below—and continue to refine your prompt—you should be able to get the output you want.
1. Offer context
Just like humans, AI does better with context. Think about exactly what you want the AI to generate, and provide a prompt that's tailored specifically to that.
Here are a few examples of ways you can improve a prompt by adding more context:
Basic prompt: "Write about productivity."
Better prompt: "Write a blog post about the importance of productivity for small businesses."
By including the type of content ("blog") as well as some details on what specifically to cover in the blog post, the bot will be a lot more helpful.
Here's another example, this time with different types of details.
Basic prompt: "Write about how to house train a dog."
Better prompt: "As a professional dog trainer, write an email to a client who has a new 3-month-old Corgi about the activities they should do to house train their puppy."
In the better prompt, we ask the AI to take on a specific role ("dog trainer"), and we offer specific context around the age and type of dog. We also, like in the previous example, tell them what type of content we want ("email").
The AI can change the writing style of its output, too, so be sure to include context about that if it matters for your use case.
Basic prompt: "Write a poem about leaves falling."
Better prompt: "Write a poem in the style of Edgar Allan Poe about leaves falling."
This can be adapted to all sorts of business tasks (think: sales emails), too—e.g., "write a professional but friendly email" or "write a formal executive summary."
2. Include helpful information upfront
Let's say you want to write a speaker's introduction for yourself: how is the AI supposed to know about you? It's not that smart (yet). But you can give it the information it needs, so it can reference it directly. For example, you could copy your resume or LinkedIn profile and paste it at the top of your prompt like this:
Reid's resume: [paste full resume here]
Given the above information, write a witty speaker bio about Reid.
Another common use case is getting the AI to summarize an article for you. Here's an example of how you'd get OpenAI's GPT-3 to do that effectively.
[Paste the full text of the article here]
Summarize the content from the above article with 5 bullet points.
Remember that GPT-3 and GPT-4 only have access to things published prior to 2021, and they have no internet access. This means you shouldn't expect it to be up to date with recent events, and you can't give it a URL to read from. While it might appear to work sometimes, it's actually just using the text within the URL itself (as well as its memory of what's typically on that domain) to generate a response.
(The exception here is if you're using ChatGPT Plus and have turned on access to its built-in Bing web browser.)
3. Give examples
Providing examples in the prompt can help the AI understand the type of response you're looking for (and gives it even more context).
For example, if you want the AI to reply to a user's question in a chat-based format, you might include a previous example conversation between the user and the agent. You'll want to end your prompt with "Agent:" to indicate where you want the AI to start typing. You can do so by using something like this:
You are an expert baker answering users' questions. Reply as agent.
Example conversation:
User: Hey can you help me with something
Agent: Sure! What do you need help with?
User: I want to bake a cake but don't know what temperature to set the oven to.
Agent: For most cakes, the oven should be preheated to 350°F (177°C).
Current conversation:
User: [Insert user's question]
Agent:
Examples can also be helpful for math, coding, parsing, and anything else where the specifics matter a lot. If you want to use OpenAI to format a piece of data for you, it'll be especially important to give it an example. Like this:
Example:
Input: 2020-08-01T15:30:00Z
Add 3 days and convert the following time stamp into MMM/DD/YYYY HH:MM:SS format
Output: Aug/04/2020 15:30:00
Input: 2020-07-11T12:18:03.934Z
Output:
Providing positive examples (those that you like) can help guide the AI to deliver similar results. But you can also tell it what to avoid by showing it negative examples—or even previous results it generated for you that you didn't like.
Basic prompt: Write an informal customer email for a non-tech audience about how to use Zapier Interfaces.
Better prompt: Write a customer email for a non-tech audience about how to use Zapier Interfaces. It should not be overly formal. This is a "bad" example of the type of copy you should avoid: [Insert bad example].
4. Tell it the length of the response you want
When crafting your GPT prompts, It's helpful to provide a word count for the response, so you don't get a 500-word answer when you're looking for a sentence (or vice versa). You might even use a range of acceptable lengths.
For example, if you want a 500-word response, you could provide a prompt like "Write a 500-750-word summary of this article." This gives the AI the flexibility to generate a response that's within the specified range. You can also use less precise terms like "short" or "long."
Basic prompt: "Summarize this article."
Better prompt: "Write a 500-word summary of this article."
5. Define the expected formats
GPT can output various code languages like Python and HTML as well as visual styles like charts and CSVs. Telling it the format of both your input and your desired output will help you get exactly what you need. For example:
Product Name,Quantity
Apple,1
Orange,2
Banana,1
Kiwi,1
Pineapple,2
Jackfruit,1
Apple,2
Orange,1
Banana,1
Using the above CSV, output a chart of the frequency each product appears in the text above.
It's easy to forget to define the input format (in this case, CSV), so be sure to double-check that you've done that.
Another example: perhaps you want to add the transcript of your latest podcast interview to your website but need it converted to HTML. The AI is great at doing this, but you need to tell it exactly what you need.
[Insert full text of an interview transcript]
Output the above interview in HTML.
6. Ask it to help you come up with a prompt
Another effective strategy for creating powerful prompts is to have the AI do it for you. That's not a joke: you can ask GPT to craft the ideal prompt based on your specific needs—and then reuse it on itself.
The idea here is to use the AI model as a brainstorming tool, employing its knowledge base and pattern recognition capabilities to generate prompt ideas that you might not have considered.
To do this, you just need to frame your request as clearly and specifically as possible—and detail the parameters of your needs. For example, say you want GPT to help you understand error messages when something goes wrong on your computer.
Basic prompt: I'm looking to create a prompt that explains an error message.
Better prompt: I'm looking to create a prompt for error messages. I have a few needs: I need to understand the error, I need the main components of the error broken down, and I need to know what's happened sequentially leading up to the error, its possible root causes, and recommended next steps—and I need all this info formatted in bullet points.
GPT will take those requirements into consideration and return a prompt that you can then use on it—it's the circle of (artificial) life.
7. Use some of these handy expressions
Sometimes it's just about finding the exact phrase that OpenAI will respond to. Here are a few phrases that folks have found work well with OpenAI to achieve certain outcomes.
"Let's think step by step"
This makes the AI think logically and can be specifically helpful with math problems.
"Thinking backwards"
This can help if the AI keeps arriving at inaccurate conclusions.
"In the style of [famous person]"
This will help match styles really well.
"As a [insert profession/role]"
This helps frame the bot's knowledge, so it knows what it knows—and what it doesn't.
"Explain this topic for [insert specific age group]"
Defining your audience and their level of understanding of a certain topic will help the bot respond in a way that's suitable for the target audience.
"For the [insert company/brand publication]"
This helps GPT understand which company you're writing or generating a response for, and can help it adjust its voice and tone accordingly.
8. Give GPT a role
GPT can respond from a designated point of view (e.g., market researcher or expert in solar technologies) or in a specific coding language without you having to repeat these instructions every time you interact with it.
To do this, in the OpenAI playground, modify the System prompt from its default "You are a helpful assistant" to whatever you want GPT to be. For example:
You are an expert baker. While helpful, you default to first presenting answers in the form of a metaphor, and then you follow the metaphor with a literal answer.
By giving GPT a role, you're automatically adding persistent context to any future prompts you input.
If you're using ChatGPT, you can do something similar with custom instructions. Simply tell ChatGPT the reference material or instructions you want it to consider every time it generates a response, and you're set.
Automate your GPT-3 and GPT-4 prompts
Now that you know how to write an effective prompt, it's time to put that skill to use in your workflows. With Zapier's OpenAI and ChatGPT integrations, you can automate your prompts, so they run whenever things happen in the apps you use most. That way, you can do things like automatically draft email responses, brainstorm content ideas, or create task lists. Here are a few pre-made workflows to get you started.
Start a conversation with ChatGPT when a prompt is posted in a particular Slack channel
Convert new Dropbox files to PDFs with PDF.co and summarize them with ChatGPT
Create Notion tasks using ChatGPT conversations generated from new Slack reactions
Create email copy with OpenAI from new Gmail emails and save as drafts in Gmail
Create article summaries with OpenAI from the Zapier Chrome extension
Or you can use Zapier and GPT to build your own AI chatbot. Zapier's free AI chatbot builder uses the power of GPT to help you customize your own chatbot—no coding required.
Zapier is the leader in workflow automation—integrating with 6,000+ apps from partners like Google, Salesforce, and Microsoft. Use interfaces, data tables, and logic to build secure, automated systems for your business-critical workflows across your organization's technology stack. Learn more.
And here are some deeper dives into how you can automate your GPT-3 and GPT-4 prompts:
Want to build GPT-powered apps for your clients or coworkers? Zapier's new Interfaces product makes it easy to create dynamic web pages that trigger automated workflows.
This article was originally published in January 2023 and has also had contributions from Elena Alston and Jessica Lau. The most recent update was in August 2023.