Prompt engineering techniques
The named techniques worth knowing, what each one does, and the situations where it earns its place in your prompt.
| Technique | What it is | Use it for | Example |
|---|---|---|---|
| Zero-shot | Just the instruction, no examples. | Simple, common tasks the model already does well. | Classify this review as positive, negative or neutral. |
| Few-shot | Show 1 to 5 input → output examples before the real input. | Specific formats, labels, tone or style. | Three labelled reviews, then the new one. |
| Chain-of-thought | Ask the model to reason step by step before answering. | Maths, logic, multi-step decisions. | “Work through it step by step, then give the answer.” |
| Role prompting | Assign a persona or expertise. | Setting vocabulary, depth, and point of view. | “You are a paediatric nurse explaining to a worried parent.” |
| Structured prompts | Sections, delimiters or XML tags separating parts. | Long prompts, pasted documents, templates. | <context>…</context><task>…</task> |
| Prompt chaining | Split a job into steps; each output feeds the next prompt. | Long documents, research → outline → draft workflows. | Extract quotes → group themes → write summary. |
| Self-consistency | Generate several answers and take the most common. | Reasoning questions where accuracy matters. | Ask 5 times, compare the final answers. |
| Ask for clarification | Invite the model to ask questions before answering. | Under-specified or personal tasks. | “Ask me up to 3 questions before you start.” |
| Output priming | Start the answer yourself so the model continues in that shape. | Strict formats like JSON or a fixed opening. | End the prompt with “Answer: {”. |
| Self-critique | Ask the model to review and improve its own draft. | Writing quality, catching errors. | “List 3 weaknesses of your draft, then rewrite it.” |
| Negative prompting | Tell an image model what to steer away from. | Stable Diffusion and other diffusion models. | Negative: blurry, extra fingers, watermark |
How to combine them
Techniques stack. A support-ticket classifier might use a role (“You are a triage agent”), a structured prompt (ticket inside tags), few-shot examples (three labelled tickets) and output priming (“Label:”). A research workflow might chain three prompts, each with its own format.
The order to reach for them: clarity first, then examples, then reasoning, then structure. The prompt generator covers the first steps automatically.
Questions
What are the main prompt engineering techniques?
The core set is zero-shot, few-shot, chain-of-thought, role prompting, structured prompts with delimiters, prompt chaining and self-consistency. Most practical prompts combine two or three of them.
Which technique should I try first?
Start zero-shot with a clear task and format. If the style or format is off, add one example (few-shot). If reasoning is wrong, ask for step-by-step thinking. If tone or depth is off, add a role.
Do reasoning models still need chain-of-thought prompts?
Less so. Models with built-in reasoning already think before answering, and OpenAI advises keeping prompts for them simple and direct. Few-shot examples and clear formats still help.