All right, so we just learned about zero -shot prompting.
You can see example of a zero -shot prompt here.
We asked the model to translate a sentence from English to French, and we
just did it bare -bones.
We didn't actually give it any additional
examples or any additional training of how we wanted to do that.
It just did it, and it was able to do it successfully because of its pre -training
data and because it's a relatively simple task.
That's zero -shot prompting.
But what if we wanted the model to do something unique or something that's
really specific?
Well, for that, we can use one -shot and
few -shot prompting.
Before we dive into some specifics, you
should understand that the difference between these is simply the number of
examples, or sometimes called exemplars, that you give the model.
So in zero -shot, we had zero examples of how to translate English to French.
It just did it, and that was it.
In one -shot, we'll have one example, and
in few -shot, we'll give it two or more examples.
So let's do a really simple one -shot
prompt example.
First, I'm gonna do this with zero -shot.
I'm telling ChachiBT, I want it to multiply six by 10.
Easy enough, right?
And it gets the answer right, the answer
is 60.
But it's got this extra conversational
language in there, and that's not the format I wanted.
It says the result of multiplying six by 10 is 60.
Let's pretend I'm doing math homework, and I just wanted to repeat the question,
and have a colon, and then provide the number 60, so that I can just copy and
paste this directly into my math homework, and hand it into my teacher,
which I'm gonna put the ethics aside of that for a moment.
So let's give it an example, or a shot, and there we go.
You can see that in my prompt, I gave it an example format.
This is the shot, the one -shot.
I want the response to be multiply four
by 10, 40.
And then you can see in the response, its
output is different in the one -shot example than it is in the zero -shot example.
By providing this one example, I've made it so ChachiBT gives me a result that is
more efficient for my purposes.
This is the power of shot prompting in action.
It's a very basic example, of course, but it's showing you its usefulness.
Now let's see few -shot prompting in action, and really make things a bit more
complicated, because it's been pretty simple so far, right?
So let's say that you work at Rotten Tomatoes, the movie aggregator website,
and that the movie Interstellar was just released.
Great movie, by the way, highly recommend
you watch it.
And so a bunch of people have submitted
reviews for this, but you, as the sometimes forgetful developer that you
are, forgot to make it mandatory that reviewers include a star rating with
their review, like you can see here.
So that's a bit of a problem, right?
Well, maybe we can use ChachiBT to solve it for us.
So we do have some reviews where the reviewer voluntarily submitted the star
rating as well.
So maybe we can use those as examples to
train ChachiBT about the correlation between existing comments and the star
ratings that they normally get, so that I can then take the comments without star
ratings and assign them a star rating, that's fair.
Let's give it a try.
So here I have a draft prompt that we're
gonna use.
To start with, you can see at the top,
I've included the instruction, given a review, assign it a star rating of one to
five, pretty straightforward, clear, specific.
I've also then used delimiters to
separate the instruction from the examples.
You can see I have one at the beginning
here and one at the end.
And then I have these three examples in there.
These are the shots and there's two or more shots, so therefore it is view shot prompting.
And these are real reviews, by the way, that I pulled from Rotten Tomatoes.
I've included the review and the actual star rating that that review got.
By the way, I included three different ones sort of on the spectrum of reviews,
a five -star review, a three -star review, and a one -star review.
This one -star review, this person obviously did not like the movie
Interstellar very much, but I think it's very funny that they say dumb space nonsense.
I'm not saying I know entirely how space works, but it ain't that per chance.
I'm not sure what they mean by per chance here, but kind of funny.
And then at the bottom, I say, okay, just once you understand this, wait for me to
give you the reviews.
Okay, so let's hop into ChatGPT and try
this out.
Okay, so we're in ChatGPT, and I've
pasted my prompt in here, and you know what?
Let's make this a little fun here.
Instead of saying, I understand, I want ChatGPT to get excited about this and
say, oh, baby, here we go.
And I enter the prompt, and there you go.
Look how excited ChatGPT is.
Oh, baby, here we go.
Okay, so it acknowledges that I have provided it this information.
Essentially what I've done here is in -context training using few -shot prompting.
How cool is that?
And before we keep going, keep in mind
that this is actually harder than you might think on first glance to understand
the correlation between a review and its star rating.
These reviews don't really have much in common, right?
They're different lengths, they use different words, and the words can be
kind of wishy -washy sometimes, right?
Like a review might say it has pretty
visuals, but then they didn't like the plot, so they gave it a two -star rating
or something.
So now let's go and give ChatGPT some
real reviews for it to assign star ratings to.
Now, I did pre -select these, but I wanted to show you
that they are actual real reviews that I just chose from the Rotten Tomatoes
website, so I'm not cheating here.
So this one from Aaron gives it two
stars, says pretty visuals, okay, overarching setting, plot events, blah,
blah, blah.
So you could see, you know, this has some
good things, but also some bad things.
So it could be two stars, three stars,
four stars, if I was doing this myself, maybe.
Let's hop to ChatGPT, give it the review,
and see what it says.
Look at that, it actually rated it two stars.
So remember our hypothetical problem is that we have these reviews, but we don't
have star ratings for them, and we want ChatGPT to assign the star ratings so
that we can use them on our website, Rotten Tomatoes.
So this is evidence here, right, that ChatGPT was able to learn the correlation
between these sorts of words in the review and the star rating.
And remember, I didn't actually tell ChatGPT whether five -star was the
highest or one -star was the highest, but it was able to understand all of this
just from these examples.
Okay, so let's try another one here.
Here we have a four -star.
This one's actually quite glowing.
Really good sci -fi story, elevated by its amazing performances and emotional moments.
Gets kind of bad on the third act, though.
Overall a bit too long, kind of
forgettable at times .
This is another one that could have been two, three, four stars.
They gave it four stars, though.
Let's see how ChatGPT does.
Star rating four, look at that.
It was accurate.
It gave the same star rating that the actual human did.
Okay, let's try this one more time.
This is my favorite, movie was pretty dank.
Okay, another four -star review.
Let's see what ChatGPT thinks of that.
Not much information there, but look at that.
It was able to figure out that, I guess
it figured out the word dank is a good thing.
I don't know, I'm not that hip.
I assume dank is good.
And gives it a star rating of four, so
there you go.
This is the power of in -context
training, and specifically with few -shot prompting.
By using few -shot prompting, we were
able to get ChatGPT to do exactly what we wanted.
That's because few -shot prompting makes
the model's response more accurate and more useful for whatever purpose we want
to use it for.
As a matter of first principles, what
you're doing here is making your prompt clearer and more specific by providing
the model with examples that demonstrate exactly what you want.
And that's nice, because sometimes it's just easier to explain things by
providing examples than to explain it with words, to show instead of tell, right?
And again, this is just like interacting with a human being.
If you give someone a task to do, it's helpful to also give them some examples
of how you want it done.
Okay, great work.
We have a little bit more about few -shot prompting that I wanted to explain to
you, which I'll do so in the next lesson.
See you there.