One shot vs Multi shot Prompting

3 min read

Cover Image for One shot vs Multi shot Prompting

Prompt engineering is a name given to technique to make effective prompts to get high quality and accurate results. In a series of posts we will cover simple techniques of prompt engineering. If you have any questions or if you want to cover a specific technique do let us know.

One-shot vs multi-shot prompting.

In machine learning one-shot and multi-shot are pretty old terms. As the name suggests one shot means one example and multi-shot means multiple examples.

These terms come from machine learning in the context of classification. For example you build a model to detect the animal from a photo. A one shot classifier can tell you whether it is a Cat or not. A multi-shot classifier can tell you that it is a car, dog, horse etc. with associated probabilities.

As you can see one shot classifier might make things simple for you but the multi-shot classifier is more rich in its output.

How does one apply this logic to prompting ? It is best to understand this with an example.

One-shot prompt example

Translate this English sentence into Spanish: "The cat is sleeping on the sofa."

Spanish Translation: El gato está durmiendo en el sofá.

Now translate this sentence: "The dog is barking at the mailman."

Above prompt is an example of single shot prompting where you gave an example of what you are expecting and the model used this to give you an output.

Now, consider a multi shot prompt.

Review 1: "This movie was absolutely amazing! The acting was superb, and the plot kept me on the edge of my seat."
Sentiment: Positive

Review 2: "I found this movie to be quite boring. The story dragged on, and the characters were uninspiring."
Sentiment: Negative

Review 3: "This movie was just okay. It had some good moments, but overall it didn't leave a lasting impression."
Sentiment: Neutral

Now classify the sentiment of this review: 

"I was blown away by the stunning visuals and incredible soundtrack in this film. It's a must-see for any movie lover!"

As you can see in this prompt we basically give more information providing relationship between multiple input and output labels. The model is supposed to factor in this to generate its output.

When one-shot prompt is useful ?

One-shot prompt is useful when the information provided in the input is generic nature and the output is also expected to be generic in nature. Understand that the models are trained on internet text. Which means the models have understood the concepts commonly expressed on internet. In such prompts the model will give a very straightforward answer and pretty quickly.

One-shot prompting thus can be seen as a simplistic usage of LLM models.

When multi-shot prompt is useful ?

Multi-shot prompt is basically asking the model to build a classifier without actually building one from scratch. Multi-shot promoting is an advanced technique where you provide a model information about multiple instances of input-output relationship and expect the model to understand the complex relationships among them.

It can help the model generalize better to new, unseen examples. It can be particularly effective when the task involves nuanced distinctions, like in sentiment analysis.

Multi-shot : Ensuring quality of examples

In multi-shot prompting however it is important that you do not overwhelm the model with too many examples. If your examples are not carefully selected and are incoherent in nature, the model might end up being far too error prone. You need to also provide model a good spread of examples.

For example in sentiment analysis it is important that you provide examples of all possible sentiments else the model will never figure out an unseen sentiment.