GPT-3 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 predicts 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 prompt.
Test your prompt
There's very little chance that the first time you put your prompt into GPT-3, 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 OpenAI's GPT-3 playground or with Zapier's OpenAI integration.
GPT-3 vs. ChatGPT. GPT-3 isn'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, on the other hand, is a more raw AI that can take instructions more openly from users. The tips here are for GPT-3—but keep those chats going with ChatGPT.
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.
6 tips for writing the best GPT-3 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, 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 only has access to things published prior to 2021, and it has 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.
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.
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).
User: [Insert user's question]
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:
Add 3 days and convert the following time stamp into MMM/DD/YYYY HH:MM:SS format
Output: Aug/04/2020 15:30:00
4. Tell it the length of the response you want
It's helpful to provide a word count for the response, so you don't get a 500-word answer when you were 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-3 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:
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. 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.
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.
Automate your GPT-3 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 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 some examples of how you can automate your GPT-3 prompts:
Want to build GPT-3-powered apps for your clients or coworkers? Zapier's new Interfaces product makes it easy to create dynamic web pages that trigger automated workflows.