Prompting techniques
Few-shot prompting
Definition
Few-shot prompting means including two to five worked examples of the input-output pattern you want before making your real request. It is the fastest way to lock in a consistent format, tone or edge-case behaviour.
Few-shot works because models are exceptional pattern matchers. Showing three examples of the transformation you want communicates your conventions far more precisely than describing them, especially for anything involving formatting or style.
Example selection matters more than example count. Include a case that demonstrates each edge case you care about — the ambiguous input, the empty input, the one that should be rejected. Three well-chosen examples beat ten repetitive ones.
The trade-off is token cost. Examples occupy context on every request, so a heavily few-shot prompt costs meaningfully more at scale. For high-volume production tasks, this is a common reason to move to fine-tuning.
Example
Show: "Delivery was fast but the box arrived damaged." → Neutral. "Absolutely love this!" → Positive. "Never showed up, no refund." → Negative. Then ask for the real classification.
Related terms
Zero-shot prompting
Zero-shot prompting means asking a model to do a task with no worked examples — just an instruction. It works well for common tasks the model has seen extensively in training.
Fine-tuning
Fine-tuning continues training a pre-trained model on your own examples to specialise its behaviour. It is the right tool for teaching consistent style, format or classification behaviour — not for adding knowledge.
Prompt engineering
Prompt engineering is the practice of designing model inputs that reliably produce the output you want. It combines clear instruction-writing, structured formatting, worked examples, and systematic testing.
Chain-of-thought prompting
Chain-of-thought prompting asks a model to work through its reasoning step by step before answering. It measurably improves accuracy on maths, logic, and multi-step problems by forcing intermediate steps instead of an immediate guess.
Tree-of-thought
Tree-of-thought extends chain-of-thought by exploring several reasoning branches in parallel, evaluating each, and pursuing the most promising. It helps on problems where the first plausible path is often wrong.
Self-consistency
Self-consistency runs the same reasoning prompt several times at non-zero temperature and takes the most common answer. It trades cost for accuracy on problems with a single verifiable result.
Put this into practice
Understanding the term is step one. Our free courses and tools let you actually use it.