ChatGPT is the generative artificial intelligence (AI) tool that's taken the world by storm. While there's always the possibility it will simply make stuff up, there's a lot you can do when crafting prompts to ensure the best possible outcome. That's what we'll be exploring in this how-to.
In this article, I'll show you how to write prompts that encourage the large language model (LLM) that powers ChatGPT to provide the best possible answers.
Also: I've tested dozens of AI chatbots since ChatGPT's debut. Here's my new top pick
Writing effective prompts, known as prompt engineering, has even become a highly-paid discipline. Who knows? These tips could help you build the skills to become a prompt engineer. Apparently, these gigs can pay from$175,000 to$335,000 per year.
One of the more interesting things I had to get used to when working with ChatGPT is that you don't program it; you talk to it. As a formally trained programmer, I've had to abandon many habits when engaging with AI. Talking to it (and with it) requires a mindset shift.
When I say talk to it like a person, I mean talk to it like you would a coworker or team member. If that's hard to do, give it a name. Alexa is taken, so maybe think of it as Bob. This naming helps because when you talk to Bob, you might include conversational details and anecdotes that give your story texture.
Also: How to use ChatGPT to write code
When you're talking to a person, it would be natural for them to miss your point initially and require clarification or veer away from the topic at hand and need to be wrangled back. You might need to fill in the backstory for them or restate complex questions based on the answers they give you.
This is called interactive prompting. Don't be afraid to ask ChatGPT multi-step questions: ask, get a response, and based on that response, ask another question. I've done this myself, sometimes 10 or 20 times in a row, and gotten very powerful results. Think of this as having a conversation with ChatGPT.
Writing a ChatGPT prompt is more than just asking a one-sentence question. It often involves providing relevant background information to set the context of the query.
Let's say that you want to prepare for a marathon (for the record, I do not run, dance, or jump -- this is merely an example). You could ask ChatGPT:
How can I prepare for a marathon?
However, you'll get a far more nuanced answer if you add that you're training for your first marathon. Try this instead:
I am a beginner runner and have never run a marathon before, but I want to complete one in six months. How can I prepare for a marathon?
By giving the AI more information, you're helping it return a more focused answer.
Here are two more examples of questions that provide context:
I am planning to travel to Spain in a few months and would like to learn some basic Spanish to help me communicate with local residents. I am looking for online resources that are suitable for beginners and provide a structured and comprehensive approach to learning the language. Can you recommend some online resources for learning Spanish as a beginner?
In this case, rather than just asking about learning resources, the context helps focus the AI on learning how to communicate on the ground with local residents. Here's another example:
I am a business owner interested in exploring how blockchain technology can be used to improve supply chain efficiency and transparency. I am looking for a clear and concise explanation of the technology and examples of how it has been used in the context of supply chain management. Can you explain the concept of blockchain technology and its potential applications in supply chain management?
In this example, rather than just asking for information on blockchain and its workings, the focus is specifically on blockchain for supply chain efficiency and how it might be used in a real-world scenario.
Also: The most popular programming languages in 2024 (and what that even means)
Lastly, let's get into how to construct a detailed prompt.
One note: I limit the answer to 500 words because ChatGPT sometimes breaks when asked to produce somewhere between 500 and 700 words, leaving stories mid-sentence and not resuming properly when asked to continue. I hope future versions provide longer answers because premises like this can generate fun story beginnings:
Write a short story for me, no more than 500 words.
The story takes place in 2339, in Boston. The entire story takes place inside a Victorian-style bookstore that wouldn't be out of place in Diagon Alley. Inside the store are the following characters, all human:
The proprietor: make this person interesting and a bit unusual, give them a name and at least one skill or characteristic that influences their backstory and possibly influences the entire short story.
The helper: this is a clerk in the store. His name is Todd.
The customer and his friend: Two customers came into the store together, Jackson and Ophelia. Jackson is dressed as if he's going to a Steampunk convention, while Ophelia is clearly coming home from her day working in a professional office.
Another customer is Evangeline, a regular customer in the store, in her mid-40s. Yet another customer is Archibald, a man who could be anywhere from 40 to 70 years old. He has a mysterious air about himself and seems both somewhat grandiose and secretive. There is something about Archibald that makes the others uncomfortable.
A typical concept in retail sales is that there's always more inventory "in the back," where there's a storeroom for additional goods that might not be shown on the shelves where customers browse. The premise of this story is that there is something very unusual about this store's "in the back."
Put it all together and tell something compelling and fun.
You can see how the detail provides more for the AI to work with. First, feed "Write me a story about a bookstore" into ChatGPT and see what it gives you. Then feed in the above prompt, and you'll see the difference.
One of ChatGPT's coolest features is that it can write from the point of view of a specific person or profession. In a previous article, I showed how you can make ChatGPT write like a pirate or Shakespeare, but you can also have it write like a teacher, a marketing executive, a fiction writer -- anyone you want.
Also: Have 10 hours? IBM will train you in AI fundamentals - for free
For example, I can ask ChatGPT to describe the Amazon Echo smart home device from the point of view of a product manager, a caregiver, or a journalist in three separate prompts:
From the point of view of its product manager, describe the Amazon Echo Alexa device.
From the point of view of an adult child caring for an elderly parent, describe the Amazon Echo Alexa device.
From the point of view of a journalist, describe the Amazon Echo Alexa device.
Try dropping these three prompts into ChatGPT to see its complete response.
I've pulled a few lines from ChatGPT's responses so you can see how it interprets different perspectives.
From the product manager identity: I can confidently say that this is one of the most innovative and revolutionary products in the smart home industry.
From the caregiver identity: The device's ability to set reminders and alarms can be particularly helpful for elderly individuals who may have trouble remembering to take their medication or attend appointments.
Also: How to use Claude (and how it's different from ChatGPT)
And from the journalist identity: From a journalistic perspective, the Echo has made headlines due to privacy concerns surrounding the collection and storage of user data.
You can see how different identities allow the AI to provide different perspectives as part of its response. To expand this, you can let the AI do a thought experiment. Let's look at some of the issues that went into the creation of something like Alexa:
The year is 2012. Siri has been out for the iPhone for about a year, but nothing like an Alexa smart home device has been released. The scene is an Amazon board meeting where the Echo smart assistant based on Alexa has just been proposed.
Provide the arguments, pro and con, that board members at that meeting would have been likely to discuss as part of their process of deciding whether or not to approve spending to invest in developing the device.
Feel free to also include participation by engineering design experts and product champions, if that provides more comprehensive perspective.
It's also good to know that making minor changes to your prompts can significantly change ChatGPT's response. For example, when I changed the phrase, "Provide the arguments, pro and con, that..." to "Provide the pro and con arguments as dialogue, that...," ChatGPT rewrote its answer, switching from a list of enumerated pros and cons to an actual dialogue between participants.
As mentioned above, ChatGPT tends to go off the rails, lose track of the discussion, or completely fabricate answers.
There are a few techniques you can use to help keep it on track and honest.
One of my favorite things to do is ask ChatGPT to justify its responses. I'll use phrases like "Why do you think that?" or "What evidence supports your answer?" The AI will often apologize for making stuff up and come back with a new answer. Other times, it might give you some useful information about its reasoning path. In any case, don't forget to apply the tips I provide for having ChatGPT cite sources.
Also: My two favorite ChatGPT Plus features and the remarkable things I can do with them
If you have a fairly long conversation with ChatGPT, you'll start to notice that the AI loses the thread. Not that that's unique to AIs -- even in extended conversations with humans, someone is bound to get lost. That said, you can gently guide the AI back on track by reminding it what the topic is and what you're trying to explore.
I've had some luck by telling the AI to re-read my prompt. Basically, the technique is to issue a prompt, then tell the AI something like: "re-read this," and follow that up with the exact prompt passed earlier. You could refine or add to the prompt if you want, and see what happens. The idea is that re-reading forces the AI to rethink and clarify what it just read.
I've had some luck by telling the AI to re-read my prompt. Basically, the technique is to issue a prompt, then tell the AI something like: "re-read this," and follow that up with the exact prompt passed earlier. You could refine or add to the prompt if you want, and see what happens. The idea is that re-reading forces the AI to rethink and clarify what it just read.
Also: Google's Gems are a gentle introduction to AI prompt engineering
This may seem silly, but think about the analog in human conversation. You're talking to someone, even right in the middle of a deep conversation. But their eyes seem blank and they're expression is a million miles away. Whether they suddenly began to daydream about getting another cup of coffee or your conversation set off a long dormant memory, it's clear they're not following along.
So, you repeat your statement. Sometimes you do it with annoyance, but, "hey, did you hear me say..." is not uncommon, right? So, telling the AI, "re-read the prompt one more time: I am a beginner runner and have never run a marathon before, but I want to complete one in six months. How can I prepare for a marathon?" may bring the AI back on track and get it to become more engaged.
Here's a fascinating academic paper on the topic. Well worth reading...and re-reading.
One of the best ways to up your skill at this craft is to play around with what the chatbot can do.
Try feeding ChatGPT a variety of interesting prompts to see what it will do with them. Then change them up and see what happens. Here are five to get you started:
Also: If you want a career in AI, start with these 5 steps
Pay attention not only to what the AI generates but how it generates what it does, what mistakes it makes, and where it seems to run into limits. All of that detail will help you expand your prompting horizons.
Part of what makes ChatGPT so compelling is you can ask it almost anything. That said, keep in mind that it's designed to provide written answers. If you want a list of websites, you're better off talking to Google.
Also: How to use DALL-E 3 in ChatGPT
If you want some form of computation, talk to Wolfram Alpha. Give ChatGPT open-ended prompts, encourage creativity, and don't be afraid to share personal experiences or emotions. Plus, keep in mind that the AI's knowledge ends in 2021 for ChatGPT 3.5 and December 2023 for ChatGPT 4 in ChatGPT Plus and ChatGPT 4o, which is available in both Plus and free modes.
You can directly specify the complexity level by including it in your prompt. Add "... at a high school level" or "... at a level intended for a Ph.D. to understand" to the end of your question. You can also increase the complexity of output by increasing the richness of your input. The more you provide in your prompt, the more detailed and nuanced ChatGPT's response will be. You can also include other specific instructions, like "Give me a summary," "Explain in detail," or "Provide a technical description."
Also: How does ChatGPT actually work?
You can also pre-define profiles. For example, you could say "When evaluating something for a manager, assume an individual with a four-year business college education, a lack of detailed technical understanding, and a fairly limited attention span, who likes to get answers that are clear and concise. When evaluating something for a programmer, assume considerable technical knowledge, an enjoyment of geek and science fiction references, and a desire for a complete answer. Accuracy is deeply important to programmers, so double-check your work."
If you ask ChatGPT to "explain C++ to a manager" and "explain C++ to a programmer," you'll see how the responses differ.
In the same way that you can adjust the complexity level, you can adjust the creativity level. It's a matter of providing a prompt that guides the AI in that direction. For example, use "please include creative, open-ended responses" or "please provide factual, concise replies" in your prompts.
There are some guardrails built into ChatGPT. It tends to shut down if you ask it political questions, for example. That's what's built into the system. While you might be able to tease out an answer, it's probably not going to provide great value. That said, feel free to keep trying with different phrasing or perspectives.
You can follow my day-to-day project updates on social media. Be sure to subscribe to my weekly update newsletter on Substack, and follow me on Twitter at @DavidGewirtz, on Facebook at Facebook.com/DavidGewirtz, on Instagram at Instagram.com/DavidGewirtz, and on YouTube at YouTube.com/DavidGewirtzTV.