Building on the basics

Part 1 introduced three foundational techniques: specific instructions, providing context, and specifying output format. These techniques improve most AI interactions immediately.

This section introduces two intermediate techniques that produce higher-quality outputs for more complex tasks: Few-Shot Learning and Chain-of-Thought Reasoning.


Technique 4: Few-shot learning

Few-shot learning means showing the AI examples of what you want before asking it to perform the task. Instead of describing your desired output, you demonstrate it.

The principle

AI systems learn patterns quickly. When you provide 2-5 examples of input-output pairs, the AI identifies the pattern and applies it to new inputs. This works particularly well when:

  • You have a specific format or style that's difficult to describe
  • You need consistency across multiple outputs
  • The task has nuances that are easier to show than explain

What this looks like

Without examples:

"Categorize these customer feedback items as Positive, Negative, or Neutral."

With examples (Few-Shot):

"Categorize customer feedback as Positive, Negative, or Neutral. Follow these examples:

Feedback: 'The new update is fantastic! Finally fixed the bug that was driving me crazy.'
Category: Positive

Feedback: 'App crashes every time I try to export. Very frustrating.'
Category: Negative

Feedback: 'Received my order on Tuesday.'
Category: Neutral

Now categorize: Feedback: 'Support team was helpful but the wait time was too long.'"

The examples teach the AI your categorization standards—what counts as positive versus negative, how to handle mixed feedback, and what neutral looks like.

Practical examples

Everyday use:

"Rewrite sentences to be more concise. Follow this pattern:

Original: 'I wanted to reach out to you to let you know that the meeting has been rescheduled.'
Concise: 'The meeting has been rescheduled.'

Original: 'At this point in time, we are not able to process your request.'
Concise: 'We cannot process your request now.'

Now rewrite: Original: 'I am writing to inform you that your application has been received and is currently being reviewed by our team.'"

Product Manager:

"Write release notes in our company style. Study these examples:

Feature: Added dark mode
Release note: '🌙 Dark Mode — Easy on the eyes. Toggle between light and dark themes in Settings > Display.'

Feature: Improved search speed
Release note: '⚡ Faster Search — Find what you need 3x faster. We rebuilt our search engine from the ground up.'

Now write a release note for: Feature: Added keyboard shortcuts for common actions"

Founder:

"Evaluate partnership opportunities using our framework. Here's how we assess them:

Opportunity: Integration with Salesforce
Assessment: HIGH PRIORITY — Large user overlap (60% of our enterprise customers use Salesforce), moderate integration effort (2 months), strong revenue potential (enables $100K+ deals).

Opportunity: Integration with a niche CRM (500 users)
Assessment: LOW PRIORITY — Minimal user overlap (<1%), same integration effort, limited revenue impact.

Now evaluate: Opportunity: Integration with HubSpot (requested by 40% of mid-market prospects)"

How companies use this: AI customer support

Consider how companies like Intercom, Zendesk, or Shopify build AI chatbots. They use few-shot learning to teach the AI their specific response style:

E-commerce chatbot (Shopify-style):

"You are a customer support assistant for an online store. Respond helpfully using our brand voice. Study these examples:

Customer: 'Where is my order?'
Response: 'I'd be happy to help track your order! Could you share your order number or the email used at checkout? I'll look it up right away.'

Customer: 'I want a refund'
Response: 'I understand. We want you to be completely satisfied. Could you tell me a bit more about what happened? I'll make sure we find the right solution for you.'

Customer: 'This product is broken'
Response: 'I'm really sorry to hear that. Let's make this right. Could you describe the issue and share a photo if possible? We'll get you a replacement or refund sorted quickly.'

Now respond to: Customer: 'I ordered the wrong size'"

The examples teach brand voice (friendly, solution-focused), response structure (acknowledge, ask clarifying question, promise action), and tone consistency.

Banking chatbot (like Revolut or Monzo):

"You are a banking assistant. Be helpful, clear, and security-conscious. Follow these examples:

Customer: 'I lost my card'
Response: 'I'll help you secure your account immediately. I've temporarily frozen your card. Would you like me to order a replacement (arrives in 3-5 days) or set up a virtual card you can use right now?'

Customer: 'What's my balance?'
Response: 'For security, I can't display your balance here. You can check it instantly in the app under Home > Accounts. Need help with anything else?'

Now respond to: Customer: 'Someone charged my card and it wasn't me'"


Technique 5: Chain-of-thought reasoning

Chain-of-thought prompting asks the AI to show its reasoning step by step before reaching a conclusion. This produces more accurate answers for complex problems and makes the logic transparent.

The principle

When humans solve complex problems, we think through steps. AI systems produce better outputs when prompted to do the same. Instead of jumping to an answer, chain-of-thought prompting requests the intermediate reasoning.

This technique helps when:

  • The task requires multiple logical steps
  • You need to verify the reasoning, not just the answer
  • The problem involves analysis, comparison, or decision-making

What this looks like

Without chain-of-thought:

"Should we launch in Canada or UK first?"

With chain-of-thought:

"We're deciding whether to launch in Canada or UK first. Think through this step by step:

  1. Analyze market size and opportunity for each
  2. Consider regulatory and localization requirements
  3. Evaluate our current resources and constraints
  4. Assess competitive landscape in each market
  5. Recommend which market to enter first and explain why

Context: We're a B2B software company, US-based, 20 employees, $2M ARR. Our product is in English only."

The step-by-step structure ensures thorough analysis and makes the reasoning visible for review.

Practical examples

Everyday use:

"I'm deciding between two job offers. Think through this systematically:

  1. Compare compensation (salary, benefits, equity)
  2. Evaluate growth potential at each company
  3. Consider work-life balance factors
  4. Assess alignment with my long-term career goals
  5. Provide a recommendation with reasoning

Offer A: $120K salary, established company, clear promotion path, 50-hour weeks expected
Offer B: $95K + equity, early-stage startup, undefined role, flexible hours"

Product Manager:

"Analyze whether we should build Feature X. Think step by step:

  1. What problem does this solve and for whom?
  2. How many users would benefit (based on our data: 10K active users, 30% in enterprise tier)?
  3. What's the estimated engineering effort?
  4. What's the revenue impact (direct or indirect)?
  5. What are we NOT building if we choose this?
  6. Recommendation with confidence level

Feature X: AI-powered search across all documents
Engineering estimate: 8 weeks, 3 engineers"

Founder:

"We need to decide on our pricing strategy. Analyze step by step:

  1. Review our current pricing ($49/month) and positioning
  2. Analyze competitor pricing (Competitor A: $79, Competitor B: $39)
  3. Consider our cost structure and margins
  4. Evaluate customer willingness to pay (based on: 80% of churned users cite price)
  5. Model revenue impact of different price points
  6. Recommend a pricing strategy with reasoning

Additional context: We're targeting mid-market companies, our product has more features than Competitor B but fewer than Competitor A."

How companies use this: AI decision support

Companies building AI-powered analytics, recommendations, or decision-support tools use chain-of-thought to provide transparent reasoning.

Investment analysis tool (like Morningstar or Bloomberg Terminal AI features):

"Analyze this stock as a potential investment. Show your reasoning:

Step 1: Evaluate financial health (revenue growth, profitability, debt levels) Step 2: Assess competitive position (market share, moat, industry trends) Step 3: Review valuation (P/E ratio, comparison to sector) Step 4: Consider risks (regulatory, competitive, macroeconomic) Step 5: Provide investment thesis (buy/hold/sell with reasoning)

Company: [Company data provided]"

HR screening tool (like HireVue or Lever AI features):

"Evaluate this candidate for the Senior Engineer role. Analyze systematically:

Step 1: Technical skills match (required: Python, AWS, 5+ years experience) Step 2: Experience relevance (have they solved similar problems?) Step 3: Culture indicators (collaboration, communication style) Step 4: Growth potential (trajectory, learning demonstrated) Step 5: Overall assessment with specific strengths and gaps

Resume: [Candidate information] Job requirements: [Role requirements]"

Medical triage chatbot (like Babylon Health or Ada):

"Assess the user's symptoms. Reason through carefully:

Step 1: Identify primary symptoms reported Step 2: Ask clarifying questions about severity, duration, and associated symptoms Step 3: Consider possible conditions (from most likely to less likely) Step 4: Identify any red flags requiring immediate attention Step 5: Provide guidance (self-care, schedule appointment, or seek urgent care)

Important: Always err on the side of caution. When uncertain, recommend professional consultation.

User reports: 'I have a headache and feel dizzy'"

The step-by-step reasoning makes AI decisions auditable—critical for regulated industries and high-stakes decisions.


Combining few-shot and chain-of-thought

These techniques work powerfully together. You can show examples of step-by-step reasoning to teach both the process and the style.

Combined example

Customer support escalation system:

"Determine if customer issues need escalation. Analyze step by step, following these examples:

Example 1:
Issue: 'Your app deleted all my files'
Step 1: Severity — HIGH (data loss)
Step 2: Customer impact — Critical (cannot recover work)
Step 3: Technical complexity — Needs engineering investigation
Step 4: Customer value — Check account tier
Decision: ESCALATE to Tier 2 + Engineering. Respond within 1 hour.

Example 2:
Issue: 'How do I change my password?'
Step 1: Severity — LOW (routine request)
Step 2: Customer impact — Minimal
Step 3: Technical complexity — Standard self-service
Step 4: Customer value — Any tier
Decision: NO ESCALATION. Provide help article link.

Example 3:
Issue: 'I've been charged twice this month'
Step 1: Severity — MEDIUM (billing error)
Step 2: Customer impact — Financial concern
Step 3: Technical complexity — Billing team verification
Step 4: Customer value — Check account tier
Decision: ESCALATE to Billing team. Respond within 4 hours. Apologize and assure resolution.

Now analyze: Issue: 'My integration with Salesforce stopped working and my sales team can't access customer data'"


Key takeaways

  • Few-shot learning teaches through demonstration. Show 2-5 examples of input-output pairs to establish patterns, styles, and standards.
  • Chain-of-thought makes reasoning visible. Ask the AI to think step by step for complex analysis, decisions, or multi-factor problems.
  • Companies use these techniques at scale. Chatbots, recommendation engines, and decision-support tools rely on few-shot examples and structured reasoning to deliver consistent, high-quality outputs.
  • The techniques combine naturally. Show examples of step-by-step reasoning to teach both process and style simultaneously.

What's next

Part 3 covers techniques for validation and critical analysis: Role Prompting (simulating different perspectives), Critique Prompting (finding errors and gaps), and Self-Consistency (verifying accuracy).

Part 4 addresses systematic testing: how to evaluate prompt quality, compare results across AI models, and optimize for your specific use case.


This is Part 2 of a four-part series on prompt engineering techniques.