Prompt Engineering 101: Autocomplete, Zero-shot, One-shot, and Few-shot prompting

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everybody david shapiro here with a uh another tutorial video so i know we've started with python and i'll show you something in a minute but um one thing that has come to my attention is that uh what we really need is some some basics with prompt engineering so if you're new to um to gpt3 uh and large language models the first thing that you need to know is that these are fundamentally just autocomplete engines so you know how like you have your phone and it will have like the recommended next word it's not much different than that it's just this is infinitely more sophisticated um the model i think i always get this number wrong but it takes about 700 gigabytes of ram to run whereas your keyboard takes you know a few megabytes so this is like several thousand times larger of an auto complete engine but at the end of the day it's just an auto complete engine so let me show you what i mean this is the original davinci model which is also one of the harder ones to use because it has no fine tuning in order to make it more instruction friendly and so in this case you usually have to do you either have to allow it to auto complete what you've done or you have to give it a few examples which is called few shot prompting so we're going to start with the old stuff because if you build up an intuition for understanding that it's an autocomplete engine and that's it you'll understand how to use these models a lot better so we say bbc news china has tested their latest fusion reactor and then we just say go and see what it does um oh interesting so the last time i ran this it did something else um it looks like in this case it's listing a bunch of different news articles so this if you go to like news.google.com this is kind of what it looks like right where it's got you know the the source and then and then a title that's not what i expected it to do so let's run it again because this is just one way that it could auto complete it let's run it again and see what happens ah see now it's actually writing an article so you see how it seems at first bluff it might be completely random but what it's doing is it's matching a pattern let's see so china has tested their latest fusion reactor and it seems to be successful this will be a huge step for the country in the world you know etc etc and it gives me a youtube um link let's see let's see if this is actually a video nope not available okay so anyways it's an auto complete engine so this is what's called zero shot so zero shot is when you don't give it any examples you just want it to complete something so this was for a news article now if i give it instructions like write a uh a short story about an astronaut going to mars this is probably not going to work um see it's just it doesn't understand what i'm asking and it's just repeating it um let's do it again yeah so it's like giving instructions it's like no i actually wanted to write something like can you write the story for me um but if we reframe it like um we'll let's call it uh uh uh um uh jordan's mission to mars um a short story by uh let's say jimi hendrix i don't know um there once was a an astronaut named jordan and then let's see what happens there we go so by giving it just a little bit uh to start off with um it kind of went yeah the this looks like it was written by a little kid there was once an astronaut named jordan jordan was a brave astronaut who was the first astronaut on mars he was the first astronaut to ever walk on mars jordan was walking along the surface of mars he was walking on a sandy desert the planet looked so red yeah this is like written by a little kid so that's the best it could do to match that pattern now let's run it again and see what happens but you can see that it's just um oh this looks like a little more sophisticated but anyways so by cueing it up the end by kayla grady and it's a short story by jimi hendrix so i forgot what it was talking about anyways all right so this is zero shot where you basically you you spool it up by giving it something and then you just let it run like an auto complete engine um and so in that respect it's just a statistical model but what if you what if you have a very specific pattern that you want it to follow so you might say like um uh brainstorm um uh let's see a list of ideas to uh let's see a list of ideas of ways to survive on mars so this is something that it's probably seen in its training data like on reddit or stack exchange or whatever and so then if we do this what would you need to bring so it's not it's just asking questions it's not actually answering them so that's no good right let's do it again and see if we can get it to oh there we go okay um oh look and so then it starts it goes off matt damon [Laughter] yeah so then it completely changes topic and it's like well that's not what i wanted i wanted this list right um gather water from the water crystals okay get oxygen from the oxygen crystals this is so random find a way to grow food um find a way to build a radio so that okay so you can see where it was just like okay it just kind of goes off the rails and runs with it this was original da vinci um so how do you get it to do what you want well so what you can do then is one shot um so what i've shown you up to this point is zero shot where it's just like let me just give you an initial prompt and treat you like an autocomplete engine just like you know you hit the next thing on your your keyboard and let it go and see what happens um now what you can do then is what's called a one shot prompt so one shot prompt is where you give it one example of what you want and then and then you uh then you set it free so then i give it an example brainstorm a list i have ideas of how to survive on mars so now let's brainstorm a list of ideas of ways to survive on a deserted island okay so in this case it's called one shot because i give it one example of what i need and then because it's basically a pattern matching thing it can keep going so find food find water find shelter find a way to communicate with the outside world it basically gave me the same kind of of information here brainstorm a list of ideas to serve on a deserted island and it repeated it so you see these repetitions happening how do you get that to stop here you can do backslash n backslash n so that's newline newline so what will happen is if it gives you a double new line it'll stop whoops gather food and water find shelter oh wait it didn't stop why didn't it stop i wonder if it's um rn slash rn so there's several ways that it can do new lines so slash r is carriage return and slash n is newline um let's see if that works nope still not stopping what the actual heck that's really weird because the stop sequence should unless it might be it might be treating this like text let me do view code oh yeah so see what it did is it escaped my backslashes so while we're here let me show you something super useful if you're trying to get if you if you get a result that you like in here with all the settings and stuff you just click view code and it'll pop up and show you like oh look here's the uh here's here's what you did and so the stop sequence right here where you see it says backslash backslash n and backslash backslash n that means it's escaping it so it's removing it as a regex so it's not evaluating it like regex i want it to evaluate it like regex but it's not gonna do that so unfortunately that's not gonna work um brainstorm a list of ideas for a haunted house now that's great um uh okay so if we if we stick with this we say all right so we're brainstorming so then if we do few shot where we give it a couple different examples so let's go ahead and let it finish finish this okay so then we say all right let's take out survive and we're just saying this is brainstorming and you notice how it's doing four items for each it's copying um it's copying the pattern exactly so now we're going to give it two examples where it's it's brainstorming entirely different things brainstorm a list of ideas of ways to survive on mars brainstorm a list of ideas for a haunted house uh let's see brainstorm a list of ideas to solve climate change so completely different domains um but i shouldn't even need to put in the one because it will it will have seen this pattern so remember it's autocomplete it's an autocomplete engine but it's also a pattern matching and pattern generation engine so that's how autocomplete works it says oh i've seen this pattern before like if you start it with a bbc news article it says i've seen plenty of bbc articles why because gbt3 was chained on you know hundreds of gigabytes of internet data um okay plant trees change the way yep there you go um actually here i thought of a good stop that we can use we can say brainstorm a list there that's gonna be our new stop um okay and so you can see like um i chose i chose something that is gonna that is gonna appear in a specific place and that'll be my new stop so plant trees change the way we produce energy change the transportation system change how we use energy um okay that's great these are not the best the best examples um because it's basically what it's copying is the amount of effort put into each one so like if we were to go back and expand on each of these and i'll show you in just a second what i mean um then it would uh it would do better all right so we're building up to a few shot examples so in in the original gpt3 what you'd have to do is in order to get very consistent output you'd have to give it several examples in every single prompt and that gets real old because you're basically training it very quickly to do what you want so let's do brainstorm a list of ideas to uh let's see what are we going to try and do um let's see something completely off the wall uh build the fanciest uh gaming pc ever and then we'll take out that all right we'll see what it does okay that's not particularly fascinating get the best computer parts get the best gaming monitor get the bet get a great gaming mouse get a gaming keyboard okay great whatever none of these are particularly impressive but the point here is to show you the difference between zero shot one shot and few shot prompting let me do a quick time check all right we're at 11 minutes let's cut it off there this will be a whole series but this is just showing you the basics of think of it as an autocomplete engine and there are three primary types of problems it's zero shot one shot and few shot once you build up an intuition for how um how these language models work then you'll understand the value of like the instruct series models and other ones that are aligned and and how they're fine-tuned and why that fine-tuning makes them more useful in certain ways all right thanks for watching uh like and subscribe and consider supporting me on patreon thanks and uh see you again soon
Info
Channel: David Shapiro
Views: 28,540
Rating: undefined out of 5
Keywords: ai, artificial intelligence, python, agi, gpt3, gpt 3, gpt-3, artificial cognition, psychology, philosophy, neuroscience, cognitive neuroscience, futurism, humanity, ethics, alignment, control problem
Id: v2gD8BHOaX4
Channel Id: undefined
Length: 12min 8sec (728 seconds)
Published: Fri Jul 08 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.