Common Prompting Techniques
Common Prompting Techniques
Beyond basic structure, several proven techniques improve the quality and consistency of AI outputs.
Zero-Shot Prompting
Ask the model to perform a task with no examples. This works well for straightforward tasks.
Classify the following sentence as positive, negative, or neutral: "The product works but delivery was slow."
Few-Shot Prompting
Provide examples of the input-output pattern you want. This is one of the most effective techniques for getting consistent formatting and quality.
Classify these customer reviews:
Review: "Absolutely love this product, best purchase I've made!" → Positive
Review: "It broke after two days, very disappointed." → Negative
Review: "It does what it says, nothing more." → NeutralReview: "Great support team but the software has bugs." → ?
Chain-of-Thought Prompting
Ask the model to reason through a problem step by step before giving a final answer. This dramatically improves accuracy on complex tasks.
A company had 150 employees in January. They hired 30 people in Q1 and 15 people left. In Q2, they hired 20 more and 10 left. How many employees do they have now?
Think through this step by step before giving your final answer.
Role-Based Prompting
Assign a specific persona to shape the model's expertise and communication style.
You are a senior data engineer reviewing a junior developer's SQL query. Identify any performance issues and suggest improvements. Explain your reasoning as you would in a code review.
Iterative Refinement
Use follow-up prompts to narrow in on what you need:
- Start broad: "Summarize this document"
- Refine: "Focus specifically on the financial implications mentioned in sections 3 and 4"
- Format: "Now restructure this as three bullet points suitable for an executive brief"
Template Prompting
Create reusable prompt templates for recurring tasks. Fill in the variables each time.
Analyze the [DOCUMENT_TYPE] titled "[TITLE]" and extract:
- Key findings (max 5)
- Risks identified
- Recommended next steps
Format as a markdown document with headers for each section.
Which Technique to Use
| Situation | Best Technique |
|---|---|
| Simple classification or extraction | Zero-shot |
| Consistent formatting needed | Few-shot |
| Math, logic, or multi-step reasoning | Chain-of-thought |
| Domain-specific expertise needed | Role-based |
| Complex or nuanced output needed | Iterative refinement |
| Repeated task with different inputs | Template prompting |