All glossary terms
Cross-cutting

Few-shot prompting

Few-shot prompting provides the model with example input-output pairs in the prompt to demonstrate the desired pattern before asking it to handle the actual input. 'Here are 3 examples of how to classify emails... now classify this one'. Few-shot consistently outperforms zero-shot on tasks with structured output or unusual format requirements.

Few-shot exploits the LLM's pattern-matching capability without requiring fine-tuning. The trade-off is context cost (examples take tokens) and the risk that the model overfits to surface patterns in the examples rather than the underlying intent. Production guidance: 3-5 examples is usually the sweet spot; examples should cover the variety of cases (not all easy or all hard); the order matters (recent examples weight more); and the format should match exactly the expected output. For genuinely novel tasks, few-shot can move accuracy from 40% to 85% without any model change.

Related terms