1
00:00:03,130 --> 00:00:06,610
What are few shot prompts?

2
00:00:06,610 --> 00:00:12,880
And, uh, how do we use the few shot prompt templates in landscape?

3
00:00:13,510 --> 00:00:23,080
So if you remember, uh, until now, we have been using mostly what we call zero shot prompts.

4
00:00:23,680 --> 00:00:24,430
Yes.

5
00:00:24,430 --> 00:00:28,060
Regular instructions to the LM model.

6
00:00:29,590 --> 00:00:36,850
This usually works well with the LM model, but sometimes this is not enough.

7
00:00:36,850 --> 00:00:43,900
And this kind of prompting generates some level of mistakes or hallucinations.

8
00:00:43,900 --> 00:00:52,690
So in order to improve the quality of the output provided by the LM model, we can use a more sophisticated

9
00:00:52,690 --> 00:00:54,760
kinds of prompts.

10
00:00:55,840 --> 00:01:05,560
Uh, the most popular is the few shot prompt, which includes not only instructions but also examples.

11
00:01:05,560 --> 00:01:13,240
So we provide the LM model a few examples of what we mean with our instructions, so he can be more

12
00:01:13,240 --> 00:01:15,970
aware of what we try to do.

13
00:01:15,970 --> 00:01:24,190
For example here here you have on the right if we are, uh, trying, uh, the LM model to classify

14
00:01:24,190 --> 00:01:31,270
the sentiment of a book review or a product review, we can provide a few examples of a positive review,

15
00:01:31,270 --> 00:01:33,280
negative review or neutral review.

16
00:01:33,280 --> 00:01:38,380
So the LM understands exactly what we are looking for.

17
00:01:39,160 --> 00:01:45,460
There is a little bit more sophisticated kind of prompt which is chain of thought.

18
00:01:45,460 --> 00:01:54,010
And this kind of prompt not only includes instructions and examples, it also includes explanations

19
00:01:54,010 --> 00:01:58,030
about the reasoning logic behind each of the examples provided.

20
00:01:58,030 --> 00:02:05,980
So if this was a chain of thought prompt, we would include here an explanation explaining the LM model,

21
00:02:05,980 --> 00:02:12,520
why this review is positive okay and why this review is negative, neutral, etc..

22
00:02:12,520 --> 00:02:17,470
So the most popular kind of prompt is the first one.

23
00:02:17,710 --> 00:02:20,590
The second one is also very popular.

24
00:02:20,590 --> 00:02:22,270
The third one is less popular.

25
00:02:22,270 --> 00:02:29,410
So in this exercise we are going to focus on uh how to do the first two.

26
00:02:29,410 --> 00:02:37,090
And we will give you, you know, with the long chain documentation to experiment and practice further.

27
00:02:37,090 --> 00:02:46,660
So the first thing we do as usual is to, uh, load the dotenv file where our credentials are in order

28
00:02:46,660 --> 00:02:54,190
to, uh, connect with the OpenAI, uh, API and being able to connect with ChatGPT, etc..

29
00:02:54,370 --> 00:02:59,710
So zero shot prompting is what we have been doing until now.

30
00:02:59,710 --> 00:03:05,050
So it's nothing new for you in this case, uh, we are importing prompt template.

31
00:03:05,590 --> 00:03:09,340
We are creating the, the the prompt template.

32
00:03:09,340 --> 00:03:17,980
We are a entering the user input and we are getting their response okay.

33
00:03:17,980 --> 00:03:27,640
So this is a small application when we want or we want the LM to classify the sentiment of our review

34
00:03:27,640 --> 00:03:28,060
okay.

35
00:03:28,060 --> 00:03:32,050
So we enter a review I love this course.

36
00:03:32,050 --> 00:03:34,390
And we get the response.

37
00:03:34,390 --> 00:03:35,440
The LM is telling us.

38
00:03:35,440 --> 00:03:37,120
This is a positive review.

39
00:03:37,120 --> 00:03:37,690
Excellent.

40
00:03:38,700 --> 00:03:42,900
Second kind of prompting few shot prompting.

41
00:03:43,590 --> 00:03:53,310
We can do this in many different ways, as I show you before, we could do it inside the prompt definition

42
00:03:53,310 --> 00:04:02,610
so we can build a prompt or a prompt template that has the same thing that the previous one had, and

43
00:04:02,610 --> 00:04:05,040
also including the examples.

44
00:04:05,040 --> 00:04:08,640
Or we can have a different approach.

45
00:04:08,640 --> 00:04:13,710
This second approach is using the few shot prompt template module.

46
00:04:13,920 --> 00:04:22,620
And in this approach what we do is first we create a variable including all the examples.

47
00:04:22,830 --> 00:04:27,840
And then we follow the the the the the classic approach.

48
00:04:27,840 --> 00:04:36,660
We create a template a classic template a, and then we create a second prompt template using the few

49
00:04:36,660 --> 00:04:38,340
shot prompt template module.

50
00:04:38,340 --> 00:04:45,300
And here the main difference is to use this examples uh settings okay.

51
00:04:45,300 --> 00:04:52,410
So in this example settings we need to refer the variable that we have created with the examples.

52
00:04:52,410 --> 00:04:54,150
And that's it okay.

53
00:04:54,150 --> 00:05:02,100
So for you to understand that we have different kinds of prompting that you can experiment and try different

54
00:05:02,100 --> 00:05:06,090
ones in a in the land change documentation.

