From the course: Prompt Engineering with ChatGPT

Providing context and using delimiters - ChatGPT Tutorial

From the course: Prompt Engineering with ChatGPT

Providing context and using delimiters

- Providing context is one of the best ways to get more out of ChatGPT. Doing so will likely improve ChatGPT's accuracy. It will simplify the chat, cutting down on the unnecessary back and forth in the conversation with ChatGPT. And finally, you'll be much more likely to get an output that is tailored to your needs and is unique to your use case. Let's take a look at two examples. On one side, we have a rather vague prompt, "Write an apology email for a late shipment." It doesn't say a shipment of what or to whom this email is, and it leaves a lot for ChatGPT to sort of guess. Then, we have this slightly better prompt with more context. It says, "Our company Red30 Tech Imports GPUs. Our products are used for on-premise AI applications. A shipment of three GPUs is two weeks late due to supply-chain issues. Write a formal apology to our client. Take full responsibility and offer a 10-percent discount. The client is Binaryville Robots." Now at a glance, it looks like the second prompt I read with more context takes a bit more work to put together, but let's look at what happens when we input both of them into ChatGPT. So, I'll start off with the more vague example. Here's our output, and notice that this is more of a template for an apology email and less of an apology message. You'll see that there are a lot of these bracketed sections that ChatGPT asks us to fill in, and there's still a lot of work to be done here. You'll notice that ChatGPT has to come up with things and sometimes these things may not be things that we want in our messages, but we've left a lot of guesswork for the system. So, in a sense, if we were to keep going with this, we would have to do quite a bit more work. But what happens when we use this prompt that has more context, that took a bit longer to write, but still just a few sentences with exactly what it is we need? I'm going to go ahead and clear my conversation. I'll add this prompt. The results here are almost a finished product. There's not a lot of places where we have to fill in blanks. This is less of a template and more of an actual message. We would still want to review this and double check that what we intended is there and only what we intended is there. But still this is much less work than having a template to work off of. Also, what is the likelihood of another ChatGPT user receiving something similar to this? It's highly unlikely because this is extremely tailored to our needs. So, having plenty of context will result in an output that we can identify as ours and we know is quite unique to our use case. Now, what if our context is a chunk of text or a bunch of code that we want to send along as part of our prompt? For that, it's a good idea to use delimiters. Delimiters allow us to nicely divide our prompt and show ChatGPT where different portions of the prompt start and end. For example, if we were to bring in some text about the planet Jupiter, we can ask ChatGPT to summarize the following article for a 10th grader. We would then use these triple quotes as our delimiter in the beginning of the text and to denote the end of the text. For code, we could use HTML, we can also use a markdown-like language, for example, these three ticks and then write the name of the language, which is Python here. And then at the end after the code example, we can close things off with three additional ticks. Now, using delimiters will help ChatGPT interpret our prompts better. We can also have neat reusable prompt templates where what's in the delimiters produces different outputs. Finally, we can use the limiters to show ChatGPT what kind of outputs we want. Let's take a look at how we can use delimiters in our prompt. Here's an article about Jupiter, and I'm going to go ahead and highlight some of it. Now I'll head over to ChatGPT and clear things up, and I'll type in, "Summarize this article for a 2nd grader." I'll use three quotes as my delimiters. And I like to start them off, create some space here and then close them off. That way I can just paste my here. And I have this nice little summary that ChatGPT has put together. So, as you can see, using delimiters will help ChatGPT understand where your example starts and where it ends.

Contents