What are few shot prompts?
And, uh, how do we use the few shot prompt templates in landscape?
So if you remember, uh, until now, we have been using mostly what we call zero shot prompts.
Yes.
Regular instructions to the LM model.
This usually works well with the LM model, but sometimes this is not enough.
And this kind of prompting generates some level of mistakes or hallucinations.
So in order to improve the quality of the output provided by the LM model, we can use a more sophisticated
kinds of prompts.
Uh, the most popular is the few shot prompt, which includes not only instructions but also examples.
So we provide the LM model a few examples of what we mean with our instructions, so he can be more
aware of what we try to do.
For example here here you have on the right if we are, uh, trying, uh, the LM model to classify
the sentiment of a book review or a product review, we can provide a few examples of a positive review,
negative review or neutral review.
So the LM understands exactly what we are looking for.
There is a little bit more sophisticated kind of prompt which is chain of thought.
And this kind of prompt not only includes instructions and examples, it also includes explanations
about the reasoning logic behind each of the examples provided.
So if this was a chain of thought prompt, we would include here an explanation explaining the LM model,
why this review is positive okay and why this review is negative, neutral, etc..
So the most popular kind of prompt is the first one.
The second one is also very popular.
The third one is less popular.
So in this exercise we are going to focus on uh how to do the first two.
And we will give you, you know, with the long chain documentation to experiment and practice further.
So the first thing we do as usual is to, uh, load the dotenv file where our credentials are in order
to, uh, connect with the OpenAI, uh, API and being able to connect with ChatGPT, etc..
So zero shot prompting is what we have been doing until now.
So it's nothing new for you in this case, uh, we are importing prompt template.
We are creating the, the the prompt template.
We are a entering the user input and we are getting their response okay.
So this is a small application when we want or we want the LM to classify the sentiment of our review
okay.
So we enter a review I love this course.
And we get the response.
The LM is telling us.
This is a positive review.
Excellent.
Second kind of prompting few shot prompting.
We can do this in many different ways, as I show you before, we could do it inside the prompt definition
so we can build a prompt or a prompt template that has the same thing that the previous one had, and
also including the examples.
Or we can have a different approach.
This second approach is using the few shot prompt template module.
And in this approach what we do is first we create a variable including all the examples.
And then we follow the the the the the classic approach.
We create a template a classic template a, and then we create a second prompt template using the few
shot prompt template module.
And here the main difference is to use this examples uh settings okay.
So in this example settings we need to refer the variable that we have created with the examples.
And that's it okay.
So for you to understand that we have different kinds of prompting that you can experiment and try different
ones in a in the land change documentation.