From the course: Getting Hands-On with GPT-4: Tips and Tricks

Using chain-of-thought reasoning - GPT Tutorial

From the course: Getting Hands-On with GPT-4: Tips and Tricks

Using chain-of-thought reasoning

- [Instructor] Remember in school when your teacher would ask you to explain your thinking on homework? In the LLM space, this approach is called chain-of-thought reasoning and can be applied to improve our prompting when using AI tools. Show you how this works. Let's talk about a word puzzle that has a series of operations. Normally, GPT 4 is really good at these puzzles, but I found one that doesn't work. So let's go ahead and grab our puzzle from the exercise folder under 02_03. Copy this in and let's paste it in. Now the idea of this puzzle is to take the first and last letters of a sentence, so she ate a pretzel over the sea, transform it, and then find a new word in the sentence. So let's hit Enter. GPT 4 made a mistake. It didn't see that sea was at the beginning of this new sequence. It thought it was somewhere towards the end. So let's use chain-of-thought reasoning to improve this. I'm going to paste in my prompt again and I'm going to type in let's think step by step. So this is going to force GPT 4 to explain its thinking. Okay, in this case, it still didn't work. It might've worked for you because you might've gotten lucky with some of GPT 4's randomness, but let's make this even more likely to be correct. Let's add an example using one-shot learning. So back to our exercise files and we're going to copy the final prompt. I'm going to refresh the page to get a new chat window and I'm going to paste it in. Now let's hit Enter. Okay, there we go. So interestingly, GPT 4 did not find let even though we can see it here from position six to seven to eight. Now this might have happened because it's looking for capitalization. So let's say ignore capitalization. And there we go. We got the correct answer. So we've learned today how we can use chain-of-thought reasoning to have GPT 4 explain its thinking and also use one-shot learning when chain-of-thought reasoning is still not enough. And this is a technique we can use to handle more complicated prompts and tasks.

Contents