How to write better ChatGPT prompts (and this applies to most other text-based AIs, too)

sample-image-16-9-red.jpg

David Gewirtz/ZDNET

GIGO. It's an acronym dating back to 1957, when the U.S. Army's William Mellin explained to a newspaper reporter that computers were limited by their input. It means “Garbage In, Garbage Out” and it applies as much to today's incredible generative AI tools as it did back in 1957 to those clunky old tube-based computing devices.

Also: AI could automate 25% of all jobs. Here's which are most (and least) at risk

In the case of an AI like ChatGPT, there's a lot of opportunity for both garbage in and garbage out. Keep in mind that we really don't have any idea what's been fed into it as part of its training. We know that its perception of facts is so fluid, it's practically qualified to be an American politician. In fact, OpenAI (the makers of ChatGPT) co-founder John Schulman says, “Our biggest concern was around factuality, because the model likes to fabricate things.”

Keep that in mind, because no matter how good your prompts are, there's always the possibility that the AI will simply make stuff up. That said, 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.

How to create effective ChatGPT prompts

To avoid the GIGO factor, your best bet is to write prompts that encourage the LLM (large language model) within ChatGPT to provide the best possible answers. 

Also: How to use ChatGPT to create an app

In fact, writing effective prompts has become its own highly-paid discipline, “prompt engineering.” ZDNET's Sabrina Ortiz wrote an article entitled, “Do you like asking ChatGPT questions? You could get paid (a lot) for it,” that explored this new employment category.

So, pay attention to the rest of this article. Who knows? Reading it could help you build the skills to become one of those highly-paid prompt engineers. Apparently, these gigs can pay from $175,000 to $335,000 per year. Hmm… See ya!

One of the more interesting things I've had to get used to when working with ChatGPT is that you don't program it, you talk with it. As a formally trained programmer, I've had to leave a lot of habits by the wayside when engaging with the AI. Talking to it (and with it), requires a mindset shift.

Also: How to use ChatGPT to write code

When I say talk to it like a person, I mean talk to it like you would a co-worker or team member. If that's hard to do, give it a name. Alexa is taken, so maybe think of it as “Bob.” This helps, because when you talk to Bob, you might include conversational details, little anecdotes that give your story texture, a variety of possibilities, and more.

When talking to a person, it would be natural to expect someone to miss your point initially and require clarification. It would be natural for someone you're talking to to veer away from the topic at hand and need to be wrangled back on topic. It would be natural to fill in the backstory and ask complex questions, and it would also be natural to have to dig in, restating some of those questions based on the answers you got back.

All of this is how you should talk to 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. You could ask ChatGPT:

How can I prepare for a marathon?

But you'll get a far more nuanced question if, instead, you tell it that you're training for your first marathon. The answers you get will be more focused to your needs, as in:

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?

Do you see how you're giving the AI much more information with which to provide you a more focused and helpful answer? For the record, I do not run, dance, or jump. So this is merely an example. Ain't no way I'm going to run a marathon (unless I'm doing it with a V-Twin motor under my seat). 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 how it works, the focus is specifically on blockchain for supply chain efficiency and how it might be used in a real-world scenario. Go ahead and feed that prompt into ChatGPT. Its answer is very interesting.

Also: Okay, so ChatGPT just debugged my code. For real.

I'll give you one more example that's far more in-depth. It shows how to construct a detailed prompt. One note: I limit the answer to 500 words because ChatGPT seems to break somewhere between 500 and 700 words, leaving the stories in mid-sentence and not resuming properly when asked to continue. I'm hoping future versions can provide more extensive answers, because premises like the one I'm about to share seem to generate some really 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 clearing 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 for 40 to 70 years old. He as 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 more detail provides more the AI can 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. A few months ago, I showed how you can make ChatGPT write like it was a pirate or Shakespeare, but you can also have it write like it's a teacher, a marketing exec, a journalist, or any other perspective you want it to consider.

Also: I asked ChatGPT write a WordPress plugin I needed. It did it in less than 5 minutes   

Here's an example. I'll ask ChatGPT to describe the Amazon Echo smart home device, but do so from the point of view of a product manager, a caregiver, and a journalist. Here are those three 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.

You can drop these three prompts into ChatGPT to see its complete response. But a few sentences will show you how ChatGPT takes on the different roles to provide different responses. 

The AI's response using the product manager identity included this sentence: I can confidently say that this is one of the most innovative and revolutionary products in the smart home industry.

The AI's response using the caregiver identity included this sentence: 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 ChatGPT to write Excel formulas

And the AI's response using the journalist identity included this sentence: 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. I'll expand that idea a bit by showing you how to let the AI do a thought experiment. Let's look at some of the issues that went into the creation of something like an 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.

Here's a quick tip. 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 dialog, that…,” ChatGPT rewrote its answer, switching from a list of enumerated pros and cons to an actual dialog between participants.

More prompt-writing tips 

  • Feel free to re-ask the question. ChatGPT will often change its answer with each ask.
  • Make small changes to your prompts to guide it into giving you a better answer.
  • ChatGPT will retain its awareness of previous conversations as long as the current page is open. If you leave that page, it will lose awareness. To be clear, ChatGPT will also sometimes lose the thread of the conversation “just because,” so be aware you may need to start over from time to time.
  • Similarly, opening a new page will start the discussion with fresh responses.
  • Answers over about 500 words sometimes break down. Be sure to specify the length of the response you want.
  • You can correct and clarify prompts based on how the AI answered previously. If it's misinterpreting you, you may be able to just tell it what it missed and continue on.
  • Rephrase questions if it doesn't want to answer what you're asking. Use personas to elicit answers that it might not otherwise want to give.
  • If you want sources cited, tell it to support or justify its answers.
  • Keep experimenting.
  • Sometimes ChatGPT just fails. Keep trying, but also be willing to give up and move onto other tools. It's not perfect…yet.

What type of prompts work best with ChatGPT? 

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 talking to Google. If you want some form of computation, talk to Wolfram Alpha. Give ChatGPT open-ended prompts, encourage creativity (yeah, and we thought creativity would be strictly the purview of humans), don't be afraid to share personal experiences or emotions, and remember that the AI's knowledge ends in 2021.

What do I do if ChatGPT refuses to answer or I don't like its answer? 

There are some guardrails built into ChatGPT. It tends to close 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 asking it questions with different phrasing or perspectives. 

Also: 6 things ChatGPT can't do (and another 20 it refuses to do)

You can ask as many questions as you want (although it did once tell me I asked it too many questions and suggested I come back later). Yes, in fact, it basically said, “Go away kid, you're bothering me.” To be fair, after hours of question, I probably was. This thing can be as, or more, addictive than watching puppy videos on YouTube.


You can follow my day-to-day project updates on social media. Be sure to 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.



Source