Clarifying what is zero-shot, one-shot and few-shot prompts

Discover with examples what is zero-shot, one-shot and few-shot prompts

AIPROMPT ENGINEERING

Eduardo Domínguez Menéndez

5/16/20254 min read

LLMs are trained on large amounts of data and can answer any kind of question. But LLMs aren’t perfect, the clearer and more concise your prompt text is… the best results. They are optimally tuned into some situations such as follow instructions.

Specific techniques that take advantage of how LLMs work, as you well know is prompt engineering. One these approach is categorized the prompts as zero-shot, one-shot, and few-shot. It involves providing examples or not within the prompt.

What is a zero-shot prompt

A zero-shot prompt is the general prompting, it is the simplest type of prompt. It only provides a description of a task and some text. Zero-shot is also called “no examples".

What is a one-shot

Providing examples when creating prompts for AI models is very helpful. Examples , reducing language ambiguity and clarify your request increasing probability LLM model provides exactly what you want They are especially valuable when guiding the model toward a specific output format or pattern, such as JSON.

An example of one-shot prompt

The next prompt (marked in bold and italic) is an example, you are free to copy a see the result in ChatGPT or you favorite LLM model:

Parse a review of a movie into valid JSON:

EXAMPLE:

```Star Wars: A New Hope (1977) is a classic space adventure, though it can feel slow at times. Mark Hamill plays Luke Skywalker, who joins forces with Princess Leia (Carrie Fisher) and Han Solo (Harrison Ford) to fight the evil Empire. Iconic, but the pacing might bore some today.```

JSON response:

{

"Title": "Star Wars: A New Hope",

"Actors": [

"Mark Hamill",

"Carrie Fisher",

"Harrison Ford"

]

}

EXAMPLE:

```The Avengers ssembles a stellar cast—Robert Downey Jr., Chris Evans, Scarlett Johansson—each delivering strong, charismatic performances. The film balances humor, action, and emotion as Earth's mightiest heroes unite against Loki’s threat. With thrilling visuals and sharp dialogue, it’s an exhilarating, crowd-pleasing blockbuster that celebrates teamwork and heroism.```

JSON response:

What is a few-shot

A few-shot prompt is similar to a one-shot prompt, but instead of providing the language model with just one example, you supply multiple examples. The idea is that offering several instances of the desired pattern increases the likelihood that the model will follow it.

A rule of thumb is include 3 to 5 examples in your prompt. But number of examples needed will depend on several factors such as the task’s complexity, the quality of the examples and the capabilities of the generative AI model you’re using.

An example of one-shot prompt with the answer of Chat GPT
An example of one-shot prompt with the answer of Chat GPT

Suggested Software Applications to improve your developer workflows

Prompt Creator

Generate the best prompts forgetting prompt engineering techniques and their extra verbose while you are drafting prompt. You focus in define the details of the task and Prompt Creator creates the best prompts following a template approach which seamlessly generates the extra verbose to launch the your Chat AI the best prompts.

GIS for Developers

A tool to collect locations on a map and transform them on entities of MapKit framework to import in Xcode ready to use in your projects. Boost your productivity on GIS projects. App has two two versions: native macOS and iOS for iPad.