Zero-shot vs multi-shot prompting – Prompt Engineering

If you want to be a good prompt engineer, you need to understand and master the concept of zero-shot, one-shot, two-shot, and multi-shot prompting techniques when prompting LLM’s like ChatGPT.

These are actually very simple and important ideas. The problem is that they are poorly named because they are confusing.

What the heck is a “shot”?

Instead of calling it a “shot”, you can think of it as an “example”.

Basically, if you give the LLM one example of what you are looking for, then this is called “one-shot prompting”.

If you give the LLM two examples of what you are looking for, then that is called “two-shot prompting”.

Here are some examples to explain this:

Prompt One-shot Prompt: “Tony is a great doctor. He has worked in the same town for over 30 years: Tony: [Doctor]. Sarah is an awesome teacher. She has won many awards over her career:”

ChatGPT Response Sarah: [Teacher].

Ok great. ChatGPT actually got this perfect with just one shot prompt. The example prompt showed a couple of sentences, followed by the person’s name, colon, and then their occupation in square brackets. From that one example, ChatGPT understood that it needed to do the same thing for the second pair of sentences.

Note:

This might not always work with just a one-shot prompt. But don’t worry. In a case like this, you can always add a few more examples in your prompt.

Are you enjoying these lessons? Sign up for our free AI course lessons and discounts to our other Udemy courses.

Few shot prompt:

Few shot prompts are great if you have several examples you can feed into the LLM. The more (good) examples that an LLM has of what you are looking for, the higher the chance there is it will give you a good output.

Prompt Here is an example of a few shot prompt: 4 + 3 = {seven}, 2 + 6 = {eight}, 7 + 5 = {twelve}, 4 + 9 =

ChatGPT Response The result that ChatGPT gave me from this prompt was: 4 + 9 = {thirteen}

This is exactly what I wanted.

As you can see, I’m training the LLM to understand that I want curly brackets for my answer, and I also want the answer spelled out in words.

If I just prompted 4 + 3 = Then the output would be: 4 + 3 = 7

But since I’m showing the LLM what I want with several examples, the LLM is able to “understand” what I want, without me needing to explain it.

Note:

I tried this example twice with one-shot prompting. The first time it worked, and the second time it failed. The point is, the more clear examples you can give the LLM, the better the output will be because it will have had more time to learn the pattern of what you want.

One more useful example of multi-shot prompting:

Imagine I have a YouTube channel, and I’m brainstorming titles for my next video about explaining one-shot vs multi-shot prompting for prompt engineers.

Prompt Example multi-shot prompt: Here are my last 3 video titles: Personas: What Prompt Engineers Need to Know Chain of Thought: Number 1 Secret to Better Prompts Prompt Engineering: 5 Most Important Tips my next video about explaining one-shot vs multi-shot prompting for prompt engineers. Give me 3 example titles that have a similar style and length to my previous videos.

ChatGPT Response “One-Shot vs Multi-Shot: Essential Strategies for Prompt Engineers” “Prompting Mastery: Navigating One-Shot and Multi-Shot Techniques” “The Art of Prompting: One-Shot vs Multi-Shot Explained for Engineers”

As you can see, it did a pretty good job understanding my basic title format and gave some decent suggestions for what I could call my next video. Even if I don’t use this word for word, it is a solid starting point.

Author Andrew Best

FREE AI COURSES AND UDEMY DISCOUNTS

Get free courses on AI, Email Marketing, Growth, and Monetization strategies to grow your business and improve Your AI skills.

JOIN US

Related