WEBVTT

00:00.660 --> 00:04.830
-: All right, let's do sentiment analysis in ChatGPT.

00:04.830 --> 00:07.526
When I'm in the playground here,

00:07.526 --> 00:10.860
you can actually do this in GPT Plus as well,

00:10.860 --> 00:12.240
but I prefer to use the playground

00:12.240 --> 00:14.280
because you can mess around with the temperature,

00:14.280 --> 00:16.800
and you can set the system message as well.

00:16.800 --> 00:21.630
So, the prompt here is in a couple of parts.

00:21.630 --> 00:23.490
The first thing is the actual task,

00:23.490 --> 00:26.820
and you can have this at the top here,

00:26.820 --> 00:28.650
or you could put that into the system message.

00:28.650 --> 00:30.300
It works equally well.

00:30.300 --> 00:33.450
And then you want to provide some examples.

00:33.450 --> 00:34.656
So here are the examples

00:34.656 --> 00:37.380
and what we're doing sentiment analysis on

00:37.380 --> 00:39.480
is some product reviews.

00:39.480 --> 00:42.145
And you can see here the product review text

00:42.145 --> 00:44.070
and then this is the actual text

00:44.070 --> 00:46.680
and then I've said sentiment negative.

00:46.680 --> 00:48.990
So, I've manually gone through and then said

00:48.990 --> 00:52.470
okay this one's positive and then this one's neutral.

00:52.470 --> 00:54.000
So, I've given it one example of each.

00:54.000 --> 00:56.820
You should be able to figure out from there

00:56.820 --> 00:57.900
what the issue is.

00:57.900 --> 01:00.060
And then you've given it the last one

01:00.060 --> 01:01.710
which is a product review text

01:01.710 --> 01:03.300
of the one that you don't know yet.

01:03.300 --> 01:06.540
And then you're asking it for the sentiment for this.

01:06.540 --> 01:08.190
So that ... this is, you know,

01:08.190 --> 01:09.600
just all in one prompt.

01:09.600 --> 01:12.210
You could also just put this in the system message,

01:12.210 --> 01:13.290
if you prefer.

01:13.290 --> 01:15.120
And then you can load in

01:15.120 --> 01:16.740
kind of one product review at a time,

01:16.740 --> 01:18.450
but let's just see how this does.

01:18.450 --> 01:19.700
Just going to hit submit.

01:20.940 --> 01:23.460
And here we go, it just comes back with positive.

01:23.460 --> 01:26.970
That's really good because it's learned from these examples

01:26.970 --> 01:30.545
that all you need is just this one response.

01:30.545 --> 01:33.275
Then if you wanted to use that as code,

01:33.275 --> 01:35.490
you can click in view code here

01:35.490 --> 01:38.220
and then you can get the Python data,

01:38.220 --> 01:39.870
you have the full prompt.

01:39.870 --> 01:41.760
All you would need to do is change this prompt

01:41.760 --> 01:46.380
so that at that very last example that you put in,

01:46.380 --> 01:50.286
is going to be just the the next one in the row.

01:50.286 --> 01:55.020
So, you could actually call this once for each new review

01:55.020 --> 01:57.570
that comes in, or a whole spreadsheet of reviews,

01:57.570 --> 01:59.460
if you needed to.

01:59.460 --> 02:01.650
Cool. So that's how you do sentiment analysis.

02:01.650 --> 02:03.210
I tend to give it a few examples,

02:03.210 --> 02:06.570
kind of tell it what you need to label it as,

02:06.570 --> 02:08.400
and then just give it the last example,

02:08.400 --> 02:11.050
and it should be able to provide a pretty good label.
