Зарегистрируйтесь сейчас для лучшей персонализированной цитаты!

7 advanced ChatGPT prompt-writing tips you need to know

05 октября 2023 г Hi-network.com
Photo by JOEL SAGET/AFP via Getty Images

We've discussed how to issue effective prompts in previous articles here on .

Special Feature

The Intersection of Generative AI and Engineering

The surge of generative AI can harness tremendous potential for the engineering realm. It can also come with its challenges, as enterprises and engineers alike figure out the impact of AI on their roles, business strategies, data, solutions, and product development. What does the future roadmap look like for bringing generative AI into the software fold? decodes from all angles.

Read now

In this article, we're going to take it up a level and look at more advanced AI prompting techniques. 

We have seven very interesting approaches that will give you a much better handle on how to communicate with ChatGPT and other generative AI tools.

Also: 6 skills you need to become an AI prompt engineer

Here's how to level up your ChatGPT usage.

1. Specify output format

When you ask a question or give an assignment to ChatGPT, you can specify how it formats the reply. Imagine that you're giving an assignment to a student, where you might specify how the assignment is to be formatted when it's turned in. Here are a few examples.

What are the longest highways in the United States? List only the top four in the form of a bullet list.

Screenshot by David Gewirtz/

Present that information in a table.

Screenshot by David Gewirtz/

2. Tell it to format in HTML

You can specify a lot about how the results are displayed. For example, you can have it generate a table that you can incorporate into a web page.

What are the longest highways in the United States? List only the top four. Present the results as HTML.

Screenshot by David Gewirtz/

You can make that HTML code bigger by clicking the square in the upper-right corner of the screenshot. 

Also: The 10 best ChatGPT plugins (and how to make the most of them)

Here's where it gets interesting. You can also have the information presented using whatever style of HTML you like. There's a school of web design that doesn't like the traditional table tags, and prefers to present tables in the form of CSS -- and here's that version.

Present that information, but use CSS instead of table tags

Screenshot by David Gewirtz/

3. Iterate with multiple attempts

You often need to work with the AI to help it get to the result you want. Take our previous CSS result. Here's what it looks like:

Screenshot by David Gewirtz/

Unfortunately, that's not as pretty as I'd like. Let's see if we can remedy it.

Redo that, but please make sure the columns are all aligned. Make the headings a darker blue with white lettering presented in all capitals and bold. Make each data row a light gray, but vary the levels of gray so row 1 is light gray, row 2 is slightly darker, row 3 is light gray, and so on. Make sure the highway name is presented in bold.

I'm not going to include the generated code, because it's long. But we're getting closer:

Screenshot by David Gewirtz/

Let's try again.

That output looks really good, but the columns are still not aligned. Make sure the columns are wide enough to accommodate the text without wrapping, left align everything, and make sure all the columns (including the headings) are perfectly aligned.

Screenshot by David Gewirtz/

It's almost exactly what we're looking for, but the route is wrapping. Let's see if we can fix that.

That's almost exactly what I want, but the route is wrapping. Please make sure the route data doesn't wrap either. Keep each line of data on exactly one line.

Don't ever assume prompting is easy. But if you've ever taught programming to humans, this is exactly the sort of result you get back. It sometimes seems like they're being passive-aggressive, but it's more likely that you didn't specify your requirements carefully enough.

Screenshot by David Gewirtz/

4. Don't be afraid to use long prompts or sets of prompts

It took quite a few iterations to put together a prompt that reliably generated highway information in the format I wanted. One key approach is to make sure your prompt is very specific, but also extensive enough to have enough information for the large language model to fully understand what you're asking.

Also: Microsoft unveils first professional certificate for generative AI skills

You may also need to modify your specification. I wound up removing the line:

Create a table that uses only CSS to format the rows, columns, and cells. Do not use HTML table tags.

Instead, I just told it how I wanted the table to look and let it decide how to implement it. Here's my full, rather long prompt:

Screenshot by David Gewirtz/

I wrote that prompt in Sublime Text, a text editor, and then pasted it into ChatGPT. Here's the result, which is exactly what I wanted.

Screenshot by David Gewirtz/

As you can see, it chose to add a title, which was fine. But now that I have a working prompt, I can add some additional tweaks. For example, I went back and modified the columns specifier:

Create columns for the index number (label this "#"), highway name, length, and route

I tried changing "Limit your answer to only the top four" to "Limit your answer to only the top 20", but the AI refused to fill in all the data for all 20. So, I removed that line entirely and added a new line at the very end of the prompt:

For the purpose of this project, please provide full data results for the top 20 highways.

This actually resulted in a partial HTML output. I had to tell the AI to continue, at which point it spit out the rest of the HTML, resulting in this:

Screenshot by David Gewirtz/

5. Provide explicit constraints to a response

You just saw how I modified some response constraints for the number of answers and the columns I wanted presented. But you can use constraints for more open-ended questions as well.

Also: Human or bot? This Turing test game puts your AI-spotting skills to the test

There are limits to this type of prompt. Take this example:

Provide a summary of the key events in World War II as reported by major newspapers of the time.

Because the model wasn't trained on newspapers from World War II, it's unable to answer the question (although it does take a guess).

Likewise, you can't specify any results from "the last few years" since the model's data entry ends in 2021. That said, you can specify data that's within the scope of the model, like this:

List major space missions between 2010 and 2020

Note that we're limiting by date. But we can add further constraints. Let's limit the data to just missions from the U.S.:

List major space missions conducted by NASA between 2010 and 2020

You can also go back to the formatting approach we discussed and do something like this:

List all major space missions conducted between 2010 and 2020. Group them by nation and space agency. Make the name of the nation and space agency bold.

And you can get even more explicit. Here we include continents and specify that any continents without missions be excluded from the list.

List all major space missions conducted between 2010 and 2020. Group them by continent. Make the name of the continent bold and all capital letters. Make the nation and space agency name bold, with either title case or all caps if that's how the space agency formats its name (like NASA). If a continent did not have a space mission, do not include it on this list.

Interestingly, the AI decided to have a bit of a hallucinatory moment. It properly listed the missions and continents, but decided Russia was a continent. I ran the prompt in a second session, and that time it did not think Russia was a continent.

6. Tell it number of words, sentences, characters

Speaking of constraints, you may have noticed that ChatGPT tends not to be accurate when it comes to word count. If you tell it to limit its answer to 50 words, it sometimes goes long or short. That's because the language model works in tokens (representations of data) that do not directly correspond to individual words.

Also: This AI chatbot sums up PDFs and answers your questions about them

For example, when I told ChatGPT to "Summarize the Game of Thrones TV show", I got back 294 words over six paragraphs. But you can try to limit the response. Try out a variety of limiting terms until you determine what works best for you. For example:

Summarize the Game of Thrones TV series in 50 words 

Summarize the Game of Thrones TV series in 2 sentences 

Summarize the Game of Thrones TV series in less than 200 characters 

Summarize the Game of Thrones TV series so it will fit in a tweet

Here's another place to keep in mind the restrictions of the AI model. ChatGPT contains no training data after 2021. At that time, a tweet was limited to 280 characters. But as of February 2023, Twitter Blue (now X Premium) subscribers can have tweets as long as 4,000 characters. Telling ChatGPT to fit something in a tweet tells it to limit the response to 280 characters, because that was the sole limit back in its day.

7. Give the AI the opportunity to evaluate its answers

As we've discussed, the AI often hallucinates, providing very wrong answers. It is possible to construct conversations with the AI to arrive at more precise answers, by letting it provide intermediate conclusions. Take this simple request:

Word similar to devolve that begins with a B

As difficult as it might be to imagine, ChatGPT reliably fails with this request, often answering decay, degrade, degenerate, and other words that begin with a "D".

Screenshot by David Gewirtz/

There are a couple of challenges with this deceptively simple prompt. First, "devolve" has multiple meanings. It can mean transfer or delegate, deteriorate or decline, or inherit or receive by succession. To get a proper answer, we need to be more specific and give the AI the general meaning we want it to pursue. It also doesn't hurt to help it determine meaning by telling it we're looking for a verb, rather than a noun.

Generate a verb that starts with the letter "B" and has a similar meaning to "devolve," specifically indicating the idea of something deteriorating or getting worse.

The problem is that ChatGPT has a very difficult time (again, due to how it represents knowledge in tokens) of determining the first letter of a word. So, it's best to give the AI time to figure that out.

Determine the first letter of the generated verb

This period is what AI experts call "giving it time to breathe". Rather than just rushing out with its first answer, this approach gives the AI time to consider whether its answer is correct.

Also: The best AI art generators

Because the AI may not come up with the right answer the first time, ask it to repeat the steps until it does:

Screenshot by David Gewirtz/

And here, it works its way through until it finds an answer:

Screenshot by David Gewirtz/

Notice how it took the AI six tries before it found the right word, even though the criteria existed for the entire sequence. The second double-check "breathe" gave it the opportunity to evaluate its answer and continue until it succeeded.

Bonus tip: Access current web info

If you want to access information after 2021, you can do so by using ChatGPT Plus and the WebPilot plugin. ChatGPT Plus isn't free, but for$20/month, the service can provide some considerable added value. Here are a few articles I've written that detail how WebPilot can substantially expand your prompt:

  • My two favorite ChatGPT Plus plugins and the remarkable things I can do with them
  • ChatGPT's new web-browsing feature is a big disappointment. Use this plugin instead
  • I needed a mechanic. Here's how ChatGPT Plus helped me skip reading online reviews

Final thoughts

One thing that's really important to note is that the AI won't necessarily do what you want right out of the gate. On the example using "devolve" above, it took me almost two hours and about 20 tries to find the formula that actually worked for the AI to reliably generate a result.

Also: How I used ChatGPT and AI art tools to launch my Etsy business fast

While we're at it, keep in mind that the AI remembers what went on in the current session. So, while it might give you the right answer in the current session, the acid test is copying your prompt to a brand-new session and seeing if it works there.

Stay tuned, because not only will I be back with more advanced prompt tips, I'll also be doing some deeper dives into individual prompting problem solvers.


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.

Featured

iPhone 15 Pro review: Prepare to be dazzledGenerative AI will far surpass what ChatGPT can do. Here's everything on how the tech advancesGoogle Pixel 8 vs. Google Pixel 8 Pro: Which one is right for you?The best USB-C cables for the iPhone 15: What the experts recommend
  • iPhone 15 Pro review: Prepare to be dazzled
  • Generative AI will far surpass what ChatGPT can do. Here's everything on how the tech advances
  • Google Pixel 8 vs. Google Pixel 8 Pro: Which one is right for you?
  • The best USB-C cables for the iPhone 15: What the experts recommend

tag-icon Горячие метки: Искусственный интеллект 3. Инновации

Copyright © 2014-2024 Hi-Network.com | HAILIAN TECHNOLOGY CO., LIMITED | All Rights Reserved.