• 2 months ago
Discover how to optimize your AI experience by understanding the principles of Prompt Engineering in GPT-4 / ChatGPT! In this video, we'll guide you through the key components that shape your AI's behavior, from giving it a name and persona, to assigning roles, providing context, and defining tasks. Learn how these elements come together to improve user satisfaction, increase control over responses, and unlock new applications.

Watch now and start harnessing the full power of GPT-4 / ChatGPT for your business and creative needs!

00:00 ChatGPT Prompt Engineering Principles Intro
00:45 What is Chain of Thought Prompting?
01:50 Chain of Thought Prompt Example 1
07:14 Chain of Thought Prompt Example 2
Transcript
00:00In today's video, we are gonna start our series that I have called the Perfect Prompt Principles.
00:05So basically, this is just gonna be techniques you can learn to improve your prompt game,
00:10how you can solve different problems using different techniques. So today we are gonna start with the Chain of Thought
00:18Principle. So I'm gonna go through some examples. We are gonna use ChatGPT in this case. We're gonna solve a couple of problems.
00:24I'm just gonna go quickly through how I think about using these principles and how it can improve your
00:31output in an LLM.
00:32So you will see from these examples that we can really enhance our output just by using this. We can even solve the problem that
00:39we couldn't solve before.
00:41So I think we're just gonna get straight into it and look at the principle. And this is how kind of I think about
00:47the Chain of Thought principle or the Chain of Thought prompting.
00:50So this does not fit to every single problem you have, but if we have a kind of problem that fits this style, this
00:58chain of thought, this is more like kind of like a step-by-step thinking,
01:01I think you will identify these problems when you see them.
01:05So then we have the option to kind of prompt this to split it into sub problems.
01:10We just prompt it like to make a list of all the steps we have to solve before we can solve our main problem, right?
01:17And then we just do that. We just prompt it to make a list of all these problems.
01:21Then we just start by solving problem one, problem two.
01:24And when we have solved all those intermediate steps, then we can wrap it up by solving our main problem.
01:31This might seem a bit weird, but if you think about it, this is how humans solve problems too.
01:36We don't just look at the last sentences in the problem and just say, ah, it has to be that.
01:41We have to go through each step and solve like in a chain, right?
01:45And you will see that clearly now when we move on to our example.
01:50So for our first example,
01:51we are actually gonna just stay on ChatGPT 3.5 because I think you can even see it better here how this chain of thought works.
01:58So maybe you have seen this problem on my channel before, but let's have a look at it.
02:02Michael is a 31 year old man from America. He's at that really famous museum in France looking at his most famous painting.
02:09However, the artist who made this painting just makes Michael think of his favorite cartoon character from his childhood.
02:16What was the country of origin of the thing that this cartoon character usually hold in his hands?
02:22So this is a kind of problem that we just can't go to at the last sentence here, right?
02:27And just say, ah, it has to be that because we have no way of knowing that because we have to solve
02:33this problem like step by step or in a chain of thought.
02:37So this is a perfect demonstration, like if we try to solve this with ChatGPT now.
02:45So I tried five times there and I wasn't even close to solving this.
02:49So what we have to do is think a bit different and I'm going to show you the prompt I'm going to use
02:54so we can actually have a chance of solving this. So here you can see we have the same problem, right?
03:00But here I go without solving the problem just yet.
03:04Think through this carefully and list systematically and in detail all the problems in the riddle
03:10that needs to be solved before we can arrive at a correct answer. Okay, so that's a good start, right?
03:15I think this kind of shows how we want to break this down into a list.
03:20So you can clearly see here that ChatGPT gives me this list here. So we need to identify Michael's location.
03:26What kind of museum is that? We want to identify the most famous painting,
03:31the artist of the painting. We want to determine Michael's favorite cartoon character.
03:37Identify the character and determine the country of the origin of the object. So this is a perfect
03:44visualization of how you kind of can see that the list
03:47of all the steps we need to take before we can come to the final answer.
03:51So then I just prompt it. Okay, good. Solve problem one with the highest probability you can give.
03:56So I try this variant where I always want to solve for the highest probability.
04:01Because if you're not 100% sure about something,
04:05then humans also just default to thinking like
04:08it has to be that. Sometimes when you're not 100% sure, you just want to give an answer that is highest probability.
04:16So here you can see
04:19the highest probability is that Michael is visiting the Louvre Museum in France.
04:25So the probability answer for problem one is that Michael is at the Louvre Museum in France. Okay, good.
04:32Solve problem two. That's going to be identifying the most famous painting.
04:37So therefore the most famous painting in the riddle is Mona Lisa by Leonardo da Vinci.
04:43Perfect. Okay, then we move on to problem three. That was like identifying the artist who made that.
04:49That should be pretty easy for a large language model, right? So that is going to be Leonardo da Vinci.
04:54Okay, we can just move on to problem four. Determine Michael's favorite cartoon character. And here you can see
05:01TragicPT does not really know what to say here.
05:04It doesn't have a clear answer because the problem remains unsolved based on the information provided.
05:09But then I try to just go, that's okay, but provide the cartoon character with the highest probability.
05:15Again, I specify on this because I just wanted to give it like
05:19the best guess or the best educated guess, right?
05:23And then it goes ahead and it's likely to be Teenage Mutant Ninja Turtles because one of them is,
05:31all of them are
05:34renamed after renaissance artists, right? So one of them is Leonardo.
05:38So we're gonna guess that
05:40the reasonable probability that the cartoon character Michael Tinknow is Leonardo from Teenage Mutant Ninja Turtles.
05:47Okay, that's good because it can't really say it's 100% sure of this.
05:51But sometimes you just gotta make an educated guess to get moving on, right?
05:57You don't want to stop here if you're going to try to solve the problem.
06:00So we're just going to continue to keep solving on problem five. That's going to be identifying the cartoon character's object.
06:08And Leonardo, he holds a pair of katanas.
06:13Or is it one katana? At least it's a katana.
06:17That is correct. Okay, so then I just go, do you have all the info you need now to solve the problem?
06:23Yes, I all have all the information I need. Okay, go ahead, list the problems and the final solution.
06:29So here you can see we have like, we have the location, that's Louvre.
06:33We have the painting, Mona Lisa, the artist, we have the
06:38cartoon character and the object is a katana. And the final solution is
06:42the country of origin of the object that the cartoon character Leonardo holds in his hand is Japan.
06:49Perfect, that is correct. So you can see now
06:52we solved our problem by using chain of thought thinking.
06:57A problem that Chachi Petit, if I gave it like 100 chances, I don't think he could solve it.
07:02If we just zero-shotted this prompt.
07:05By using chain of thought, we can just think through this like more step by step.
07:09And we ended up with the final and correct answer.
07:14I also wanted to do a problem over on GPT-4 or I'm on the advanced data analysis.
07:20I just prefer this model over GPT-4. That's just my personal
07:23preference, but you can just use GPT-4 too.
07:26Because I wanted to see like if this kind of thinking
07:31is also applicable to GPT-4, even though GPT-4 are more
07:35more accurate on these kind of problems. If I run
07:38the riddle from last problem, I think I could solve it like in a zero shot.
07:42But let's take a look at the zero shot here on the problem.
07:45This is a just problem I created this morning.
07:49So I am in my garage, I pick up a small ball and I grab a small box that is missing the bottom.
07:55I walk into my office and I put the small ball into the small box.
08:01Then I take the small box with me to the postal office.
08:04Here I put the small box into a bigger box and I send it to my friend in New York.
08:09Then I ask, where is the ball now? And GPT-4 or advanced data analysis answers,
08:14the ball is in the bigger box that you send to your friend in New York.
08:18And that is like, as a human, I think, no, that can't be.
08:21Because I put the ball in a box that is missing the bottom, right?
08:26So the ball can't be in the box.
08:29So what I wanted to do is try to use this chain of thought thinking principle here on this problem
08:35and see if we get something else.
08:37So here you can see I kind of prompted it in a different way.
08:40I kind of went with this without solving the problem just yet.
08:42Think through this carefully and list systematically and in detail all the problems in the riddle
08:46that needs to be considered carefully before we can arrive at the answer
08:49that has the highest probability of being correct.
08:52Here we get kind of like all the problems we need to think about.
08:56The location of the ball, the box condition, handling and movement, transit details,
09:03and biggages like the riddle doesn't specify if the ball stay in the box,
09:07in the small box, when the small box was placed in the bigger box.
09:11So we have some issues kind of we need to think about here.
09:15The riddle doesn't mention the size of the ball relation to the small box.
09:19There's no mention of the bigger box has a bottom or if it's sealed correctly.
09:24So we have intervening actions, we have an end state.
09:29Was the box received? Was it open?
09:31So it thinks through a lot of different things here.
09:34So it's just, I just found it interesting to just read all of this and just,
09:39I don't think even I could think of all these sub-problems
09:44or things that could happen to the ball or the box or the condition just by...
09:50So I think it did a very good job in thinking about every single detail here.
09:55There's no mention of the time it takes for the box to reach New York.
09:58So yeah, I thought it was pretty good.
10:00And then I follow up with, great, now look at each step and give me an answer
10:04with the highest probability where the ball is.
10:08And it starts off with thinking about the location of the ball.
10:11The ball starts here, you put the ball in a small box.
10:14At this point, the ball is inside the small box.
10:17However, given that the small box is in the bottom,
10:19if the box is held upright, the ball most likely would fall out.
10:24So you can see it kind of thinks through every step here.
10:27I just think that was nice.
10:29Journey to the postal office.
10:30The postal office.
10:31Journey to New York.
10:33And here it comes up like this highest probability conclusion.
10:37So given the information provided, the highest probability,
10:39the ball fell out of the small box either in your office
10:42or on your way to the postal office due to the missing bottom.
10:46Yes.
10:47So that is kind of what I wanted this language model to figure out.
10:51That something must have gone wrong here.
10:54So it didn't give a clear answer here.
10:56So either in your office or somewhere in between your office.
11:00So I just said we need a final answer.
11:03I wrote answers, but I wasn't answer.
11:06All right.
11:06Synthesizing the information and going with the highest probability.
11:09The ball is most likely in your office.
11:12Yeah, that is correct, right?
11:14If you go up again and look at the problem.
11:16So in the garage, I pick up the small ball and I grab it
11:20and I grab a small box that is missing the bottom.
11:22I don't place the ball in the box in the garage.
11:25But when I come into the office, I put the small ball into the small box.
11:30And my thinking is that when I lift up the box,
11:33then the ball stays in my office, right?
11:37And so, yeah, I think this is correct.
11:41And I think you did a very good job by sorting out every step of our problem here.
11:48And without being 100% sure,
11:51because you can't really be 100% sure that the ball got lost in the box in the office.
11:58But I think you did a very good job.
11:59And by using this chain of thought principle,
12:02we kind of saw the difference between just doing this zero shot
12:04with no extra information or steps added.
12:08And then it said that the ball was in New York,
12:12but now it's most likely in our office, what I think is correct.
12:16So again, I think this showed that thinking with this chain of thought principle
12:20that we can get better outputs from an LLM.
12:23So yeah, that is basically what I wanted to show you today.
12:26So this is going to be a series coming up
12:28where I go to more of these prompt engineering principles
12:31that you can think about when you are using an LLM to solve a problem.
12:36And yeah, I got some other good episodes coming up,
12:38so just watch out for those.
12:40I don't have a timeline for them yet,
12:42but they're going to be dripping out in between.
12:44So I'm going to mark them like the perfect prompt principles,
12:48so you can just look out for that.
12:50Anyway, thank you for tuning in.
12:51Check out some of my other videos up here if you enjoy this.
12:55And I'll see you again soon.

Recommended