-: All right, let's do sentiment analysis in ChatGPT.
When I'm in the playground here,
you can actually do this in GPT Plus as well,
but I prefer to use the playground
because you can mess around with the temperature,
and you can set the system message as well.
So, the prompt here is in a couple of parts.
The first thing is the actual task,
and you can have this at the top here,
or you could put that into the system message.
It works equally well.
And then you want to provide some examples.
So here are the examples
and what we're doing sentiment analysis on
is some product reviews.
And you can see here the product review text
and then this is the actual text
and then I've said sentiment negative.
So, I've manually gone through and then said
okay this one's positive and then this one's neutral.
So, I've given it one example of each.
You should be able to figure out from there
what the issue is.
And then you've given it the last one
which is a product review text
of the one that you don't know yet.
And then you're asking it for the sentiment for this.
So that ... this is, you know,
just all in one prompt.
You could also just put this in the system message,
if you prefer.
And then you can load in
kind of one product review at a time,
but let's just see how this does.
Just going to hit submit.
And here we go, it just comes back with positive.
That's really good because it's learned from these examples
that all you need is just this one response.
Then if you wanted to use that as code,
you can click in view code here
and then you can get the Python data,
you have the full prompt.
All you would need to do is change this prompt
so that at that very last example that you put in,
is going to be just the the next one in the row.
So, you could actually call this once for each new review
that comes in, or a whole spreadsheet of reviews,
if you needed to.
Cool. So that's how you do sentiment analysis.
I tend to give it a few examples,
kind of tell it what you need to label it as,
and then just give it the last example,
and it should be able to provide a pretty good label.