Home › Glossary › Generative AI › Few-shot prompting

Intermediate · Generative AI

Few-shot prompting

Visual diagram · (in preparation) · Math · (in preparation) · Worked example · 3 difficulty levels.

TL;DR. Few-shot prompting provides a large language model with a small number of examples within the prompt to guide its response to a query.

Technical Definition

Few-shot prompting provides a large language model with a small number of examples within the prompt to guide its response to a query.

How it works

Few-shot prompting is a technique used with large language models (LLMs) where the prompt includes a few examples to demonstrate the desired task or output format. By showing the model a couple of input-output pairs, it can better understand the user's intent and generate a more relevant and accurate response, often outperforming zero-shot or one-shot methods.

Related Concepts

  • Prompt Engineering — The art of crafting effective input instructions to guide LLM behavior without changing model weights.
  • In-context learning — A technique where a language model learns to perform a task by conditioning its output on examples provided within the input prompt.

Further Reading

  • Google ML Glossary