ADVANCED ChatGPT Prompt Engineering: 7+ Chain Prompts in the Tree of Thougts Principle

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video I will show you an advanced prompting technique that involves chaining and looping seven different prompts it is based on the tree of thought principle that we looked at in my previous video so I will teach you how you can do this in the chat GPT interface and also how you can automate this with a python script so let's just get started let's start by looking at the prompt chain flow and the tree of thoughts Loop so the first prompt is basically gonna be our problem right and the second prompt is gonna brainstorm three solutions to that problem remember this is a chain so in prompt 3 we're gonna get GPT for Ultra GPT to evaluate each solution and give them a rank let's say they give them a rank of 1 to 100 and we're gonna exclude the two ideas with the lowest rank in prompt 4 and keep the winning one and here you can see we go into our Loop brainstorm two new ideas to compete with the winning ID this is the second step and again we're gonna evaluate those three IDs and rank them keep the winning idea brainstorm two new ideas and of course we're gonna keep the winning idea again we're gonna do that five times to try to find the absolute best ID and it's important that every time we we cycle through this that we keep feeding in the problem again I'm gonna show you that and after five loops and fierce competition we have a winning ID this is just gonna go to some refining and we can present the winning ID in prompt seven so what I wanted to do now is just start here on prompt one and take it step by step in chat chipity and that is gonna be ignore all previous instructions act as our psychologist and relationship expert your task is to help the user solve that problem then I just go my problem equals I think I wanna break up with my girlfriend I'm 27 years old I feel our relationship is a that stagnation Point nothing bad has happened but I figure I Grown Apart and they have different views on life they have been a couple of six years what approach should I take when telling her I am breaking up can you acknowledge this you have read my problem and answering red and don't say anything else yet okay so we get the red back here then we can move on to our next prompt and that is gonna be as you can see here brainstorming three solutions so let's just go back to chat GPT paste in our prompt I have the following problem and let me just do my problem right in Brackets could you brainstorm three distinct Solutions please consider the three most important factors that will have an impact on the outcome okay so let's just hit submit okay so we have our three solutions here so that's a direct communication approach gradual distance approach and we have the mutual decision approach okay so let's move on to prompt three and that is going to be evaluate and rank each solution so let's go back here okay so the prompt is just gonna be for each of the three proposed Solutions evaluator potential okay so let's just spin this up so hopefully now we have a ranking for each solution so you can see number one that has a potential a probability of success 85 that was quite High the second one has 70 percent and we have 60 here okay so let's move on to prompt four and that is going to be to exclude the two lowest ranked IDs and keep the winning one so if we head over to tachypt again here now I just want to do the prompt remove the two lowest rated IDs and keep and rewrite a compressed summary of only the highest rated ID including the probability score okay yes perfect here you can see it picked out the direct communication approach with the 85 probability of success okay so we can move on to our next step and that is going to be at the start of our Loop so this is quite an important step so here we're gonna brainstorm two new ideas and come to compete with the winning idea so let me show you here how I do that so I'm just going to paste in the prompt here and explain it so I'm just gonna go problem equals and here we repeat our problem for the first step winning ID This is Our Winning idea from the previous uh prompt right and now we just go could you brainstorm two new creative distinct solutions to that problem in bracket threads because we have a problem here and include the following ID that's going to be the winning idea that we have here right so we have now three IDs please consider the three most important factors that will have an impact on the outcome all right so let's spin this up now you can see that we keep the winning idea right that is the direct communication approach but now we get two new ideas and that is the whole point of this meditated communication approach I don't know what that is but and the written expression approach so the most important thing here is that we get something different that we got in the first run right that was the gradual distance approach and the mutual decision approach so the thing is now we get two new completely two new completely I two completely new ideas that will challenge the winning idea so in this way we will always try to come up with the best idea of course that is evaluated by chatibility or gpt4 so I am not gonna put you to going through these steps every single time so I'm gonna do this Loop four or five times now and I'll come back to you when we are at the end [Music] after going through the loop five times we have a winning ID and it's the direct communication approach with an 85 probability of success let me count how many other Solutions it was up against one two three four five eight nine eleven twelve and out of those 12 Solutions there was only one that was really close to building it and that was the therapeutic intervention approach with the score of 80 percent and the other ones were quite far off but that was the whole point uh but you can see when the loop is starting to repeat itself this is because we ran out of context we know right and that is the limitation of the model but we ended up with a winning solution and now let's take a look at the final result and as the final prompt that is gonna be for the winning solution deep in the thought process this is a basically a more deep analyzing of the winning idea so we have potential scenarios strategies for implementation Partnerships resources potential obstacles and solutions unexpected outcome and responses alright so this was quite good but as you can see this is very manual this takes a lot of time but it can be done it's not that much but I have made a python script that automates this full process so I just wanted to show you that because that makes it a much more easy here is the python code I created for this so you can see here we have something called run script here and you can see a summary chain one two three four five six seven eight right and we have this run Loop here so this is the loop with chain three four and five as we just did so this is just gonna do an automatic cycle of this so this can just be fully automated all we have to do is put in our problem into a prompter so you can see I have all the prompts lined up here and this is going to be chained together but I made this UI so this is easy to follow along so let's just fire up the script and take a look at the ID and run a totally new problem the first problem I wanted to run through this great was this one I saw here on a TED talk for a few weeks ago I don't know if you've seen it but let's just listen to the problem the eye is passing the bar exam does that mean that AI is robust that common sense you might assume so but you never know so suppose I left five close to dry out in the sun and it took them five hours to dry completely how long would it take to dry 30 clothes GPT 4 the newest greatest AI system says 30 hours not good so what we're gonna do is just take exactly this problem and try to run it through the script and see if we could get a different solution than 30 hours now let's fire up our script this is a web app I created for this so this is sort of a UI okay so let's just open that take a look at it over here this might take a bit the mobile to look I had to load up so you can see we have a box here we can put in our problem so I can paste in the problem here right this is the clothes problem and when this runs now you can see uh someone start the script now when this runs This is Gonna Fill Up the bar and when the bar has come all the way over here we should get our solution I'm just gonna let this run out you can watch the progress bar and let's see if we can get something other than the 30 hours thank you okay so we got the results back and this is looking quite good so let's take a deeper look here so in justification for the winning solution the winning solution drawing all 30 clothes simultaneously yes that is exactly what I was looking for the dry time let's take a look at that so the dry time for line drawing all 30 closed simultaneously is estimated to be five hours perfect that is the answer this is based on the initial observation that five cloves dried completely with in this time frame and assuming all clothes are exposed to similar environmental conditions and adequate airflow perfect that is exactly what I was looking for and that is what the AI researchered as deep D4 and couldn't get the right answer so this shows that using uh this tree of thought process this kind of chain prompting really improves reasoning and that is exactly what I wanted to show in this video so if you found this interesting and you want to try this out I have left a link in the description below to the prompts you can find a text prompt there if you want to download them if you want to learn how to set up in Python these kind of scripts and how to create a UI like this you can check out my membership that is also in the description and I have I think about 40 50 members only videos now but anyway thank you for tuning in and I hope I see you again soon bye bye
Info
Channel: All About AI
Views: 43,287
Rating: undefined out of 5
Keywords: chatgpt, prompt engineering, chat gpt, chatgpt prompt engineering, advanced prompt engineering, advanced chatgpt, chain prompting, tree of thoughts prompting, python, chatgpt python, chatgpt api
Id: j320H2LFx-U
Channel Id: undefined
Length: 10min 40sec (640 seconds)
Published: Sun May 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.