Home/Blog/Prompt Engineering Techniques: Few-Shot, Chain-of-Thought, and Role Prompting
Fundamentals10 min read

Prompt Engineering Techniques: Few-Shot, Chain-of-Thought, and Role Prompting

By Deep Prompt Hubยท
Prompt Engineering Techniques: Few-Shot, Chain-of-Thought, and Role Prompting

Three techniques account for the majority of performance gains in prompt engineering: few-shot prompting, chain-of-thought prompting, and role prompting. Understanding when and how to apply each one will transform your AI results.

Technique 1: Few-Shot Prompting

What it is: Providing examples of the input-output pattern you want before giving the actual input.

When to use it: Any time you want a specific output format, style, or structure that would be hard to describe in words alone.

Basic structure: ``` Input: [example 1] Output: [desired output 1]

Input: [example 2] Output: [desired output 2]

Input: [your actual input] Output: ```

Real example โ€” converting customer feedback to structured data:

Input: "The product arrived broken and customer service was unhelpful" Output: {"sentiment": "negative", "issues": ["product quality", "customer service"], "severity": 4}

Input: "Fast shipping but the color was different than shown" Output: {"sentiment": "mixed", "issues": ["product accuracy"], "severity": 2}

Input: "Best purchase I've made this year, exactly as described" Output:

The AI learns your JSON structure from examples and applies it consistently. Two to five examples typically maximize performance โ€” more examples rarely help significantly.

Technique 2: Chain-of-Thought Prompting

What it is: Instructing the AI to show its reasoning step by step before giving a final answer.

When to use it: Complex reasoning tasks, math problems, multi-step analysis, decision-making scenarios.

Activation phrases: - "Think step by step" - "Walk me through your reasoning" - "Before answering, outline your approach" - "Let's think about this carefully"

Why it works: Forces the model to externalize its reasoning process, catching errors before committing to a conclusion. This technique dramatically improves accuracy on logical tasks.

Example:

Without chain-of-thought: "Should I hire a contractor or full-time employee?" โ†’ Generic answer

With chain-of-thought: "I need to decide whether to hire a contractor or full-time employee. Think step by step through the financial, legal, and operational factors, then give me a recommendation." โ†’ Structured analysis that walks through each factor before concluding.

Technique 3: Role Prompting

What it is: Assigning the AI a specific identity, expertise level, or perspective before the task.

When to use it: Expert-level analysis, specialized writing styles, specific audience targeting, perspective-taking.

Effective role frames: - "Act as a [profession] with 20 years of experience in [specialty]" - "You are a [target audience member]. Evaluate this from their perspective." - "Take the role of a skeptical investor reviewing this pitch" - "You are an editor at [publication]. Review this article against their standards"

Depth matters: "Act as a marketing expert" is weaker than "Act as a Chief Marketing Officer at a B2B SaaS company with 500 employees, who has scaled companies from $1M to $50M ARR and is known for data-driven growth strategies."

Combining All Three

The most powerful prompts combine all three techniques:

*"[Role prompt] You are a senior data scientist with expertise in e-commerce analytics.*

*[Few-shot example] When analyzing customer churn, you typically structure your analysis as:* *Issue identification โ†’ Root cause analysis โ†’ Impact quantification โ†’ Recommended actions*

*[Chain-of-thought instruction] Think through each step carefully before providing your final recommendation.*

*[Actual task] Here is our customer churn data for Q1 2026: [data]. What is causing our churn and what should we do first?"*

This combination produces analysis that is consistently more structured, accurate, and actionable than any single technique alone.

More from the Blog