Few-Shot Prompting
Few-shot prompting is the technique of including a small number of input-output examples in your prompt to teach the AI model the exact pattern, format, tone, or reasoning you want. Instead of describing what you want in abstract terms, you show the model what good output looks like. For instance, rather than saying "classify these customer reviews as positive or negative," you provide three labeled examples and then present the new review for classification. The model learns the pattern from your examples and applies it consistently. Few-shot prompting is one of the most reliable ways to control output format, enforce specific styles, and improve accuracy on classification, extraction, and transformation tasks.
The number of examples matters, but more is not always better. Research and practice suggest that two to five examples typically hit the sweet spot. One example (one-shot) establishes the format but may not capture edge cases. Two to three examples let the model distinguish the pattern from coincidence. Beyond five, you often get diminishing returns while consuming valuable context window space. The quality and diversity of your examples matter far more than quantity — choose examples that cover the range of inputs the model will encounter, including edge cases and boundary conditions. If your examples are all similar, the model may overfit to that narrow pattern and handle novel inputs poorly.
Formatting your examples consistently is critical. Use clear delimiters between the input and output (like "Input:" and "Output:" labels, or XML tags), keep the structure identical across all examples, and place your actual query at the end in the same format. Few-shot prompting combines powerfully with chain-of-thought — you can show examples that include reasoning steps, teaching the model both the thinking process and the output format simultaneously. For production use, save your best few-shot prompts as templates. The examples you curate are intellectual property — they encode your domain expertise into a reusable format that consistently produces high-quality AI outputs.
Recommended tools & resources
Explore few-shot and other proven prompting structures.
Prompt TipsPractical techniques for crafting effective AI examples.
Chain of Thought PromptingCombine examples with step-by-step reasoning.
Zero-Shot PromptingWhen and why to skip examples entirely.
Prompt BuilderBuild few-shot prompts with guided example formatting.
GuidesIn-depth tutorials on advanced prompting techniques.