Learn AI

Few-Shot Prompting Explained: How to Teach AI With Examples

AI Prompting Intermediate Part 5

Sometimes the easiest way to tell AI what you want is to show it. This guide explains zero-shot, one-shot and few-shot prompting, when examples improve results, and how to build better examples.

In the previous article, we looked at prompt frameworks and how structures such as Task, Context, Constraints and Output can help organise a request.

But sometimes describing what you want is harder than simply showing it.

This is where example-based prompting becomes useful.

Instead of only telling the AI:

“Write this in the style I want.”

you can provide examples of the style, structure, classification or behaviour you want the model to follow.

This is commonly called:

few-shot prompting.

What is few-shot prompting?

Few-shot prompting means providing an AI model with a small number of examples inside the prompt before asking it to perform a similar task.

The examples demonstrate the pattern you want.

A simplified structure looks like:

INSTRUCTIONS

+

EXAMPLE 1

+

EXAMPLE 2

+

NEW INPUT

↓

MODEL PRODUCES OUTPUT USING THE DEMONSTRATED PATTERN

The model is not being permanently retrained by these examples.

The examples are part of the context for the current inference request.

Zero-shot, one-shot and few-shot prompting

You may encounter three related terms.

Zero-shot prompting

Zero-shot means you give the AI instructions but no examples.

For example:

“Classify each customer comment as Positive, Neutral or Negative.”

The model receives the task but no demonstration.

One-shot prompting

One-shot means you provide one example.

For example:

Example:

Customer comment: “The delivery was quick and the product works perfectly.”

Classification: Positive

Then you provide a new comment.

Few-shot prompting

Few-shot means you provide several examples.

For example:

Comment: “Excellent service and very fast delivery.”

Classification: Positive

Comment: “The product arrived. It works as described.”

Classification: Neutral

Comment: “The item arrived damaged and support has not responded.”

Classification: Negative

Then the model classifies a new comment using the demonstrated pattern.

Why do examples help?

Language can be ambiguous.

Imagine saying:

“Write a concise executive summary.”

What does concise mean?

100 words?

500 words?

Three bullet points?

What does an executive summary look like in your organisation?

An example can answer those questions immediately.

Examples reduce ambiguity

A good example can communicate:

  • tone;
  • structure;
  • length;
  • classification rules;
  • level of detail;
  • formatting;
  • terminology;
  • style; and
  • how edge cases should be handled.

Instead of trying to describe every characteristic in words, you demonstrate the desired pattern.

A simple writing example

Suppose you want AI to create short product descriptions.

You could say:

“Write short, energetic product descriptions.”

That leaves a lot open to interpretation.

Instead:

“Use the style demonstrated below.”

Example 1

Product: Compact travel charger

Description: Charge fast without carrying a brick. This compact USB-C charger fits easily into a laptop bag and delivers reliable everyday power at home, in the office or on the road.

Example 2

Product: Wireless desktop mouse

Description: Simple, comfortable and ready for the workday. This wireless mouse gives you reliable control without adding cables to your desk.

Then:

“Write a description for this product using a similar length, tone and structure without copying the wording.”

Examples are especially useful for style

Style can be difficult to define precisely.

For example, instructions such as:

“Make it professional but not corporate.”

or:

“Make it conversational but still authoritative.”

can mean different things to different people.

A few strong examples often communicate that style more effectively.

Do not ask the AI to copy the examples

If you provide examples, clarify whether the model should reproduce the exact wording or merely follow the pattern.

For most content tasks, a useful instruction is:

“Follow the tone, structure and level of detail demonstrated in the examples, but do not copy phrases or sentences.”

Examples can teach formatting

Suppose you need every AI-generated risk finding in this format:

Finding: Unsupported operating systems detected.

Evidence: 23 endpoints are running operating systems outside vendor support.

Business Impact: Unsupported systems may not receive security updates, increasing exposure to known vulnerabilities.

Priority: High

Recommended Action: Develop and execute an upgrade or replacement plan.

If you provide two or three findings in this format, the AI has a strong example of how new findings should be structured.

Few-shot prompting for classification

Classification is one of the strongest practical uses of few-shot examples.

Imagine you want to classify IT tickets.

Your categories are:

  • Access;
  • Hardware;
  • Software;
  • Network;
  • Security.

You could provide examples:

Input: “My password has expired and I cannot sign in.”

Category: Access

Input: “My laptop screen is flickering.”

Category: Hardware

Input: “I received an email asking me to log into Microsoft 365 using a strange link.”

Category: Security

Then ask the model to classify new requests.

Examples define your categories

This can be more useful than relying only on generic category names.

For example, your organisation may classify:

“User account locked after multiple failed passwords”

as:

Access

while another organisation might classify it under:

Identity & Security.

Examples show the AI how your taxonomy works.

Few-shot prompting for sentiment

Sentiment can contain subtle cases.

For example:

“The product works, but delivery took two weeks longer than promised.”

Is that positive?

Negative?

Mixed?

If your system allows a Mixed category, demonstrate it.

Example:

Comment: “The service was excellent, but the price was higher than expected.”

Classification: Mixed

This teaches the model how you want ambiguous cases treated.

Examples are useful for edge cases

The obvious examples are often easy.

The most valuable examples may be unusual or ambiguous cases.

Suppose you are classifying security incidents.

Simple example:

“Confirmed ransomware encryption.” → Critical

That is obvious.

A more useful example could be:

“Malware blocked successfully with no evidence of execution or persistence.” → Medium

because it demonstrates how the system handles a less obvious case.

Few-shot prompting for extraction

Examples can also help the AI understand exactly which information should be extracted.

Suppose you process customer enquiries.

Example input:

“Hi, this is Sarah Jacobs from Acme Manufacturing. Please call me on 082 555 0101. We need a quote for security awareness training for approximately 120 employees.”

Expected output:

Customer: Acme Manufacturing

Contact: Sarah Jacobs

Phone: 082 555 0101

Service: Security awareness training

Employees: 120

Then ask the model to process additional enquiries using exactly the same fields.

Few-shot prompting for structured output

For software applications, you may need machine-readable output.

For example:

{
  "customer": "Acme Manufacturing",
  "service": "Security Awareness Training",
  "employee_count": 120,
  "priority": "Normal"
}

A few examples can demonstrate the exact schema expected.

Where the AI platform supports formal structured-output schemas, those mechanisms can be even more reliable than relying on examples alone.

Few-shot prompting for business writing

Imagine your company has a particular style for executive risk findings.

You could provide three approved examples and instruct:

“Use the examples below to understand our writing style. New findings should use plain business language, explain impact before technical detail, avoid exaggerated risk claims and remain between 100 and 150 words.”

The combination of:

INSTRUCTIONS + EXAMPLES

is usually stronger than either one alone.

Example: executive risk summary

Suppose your approved example says:

“Several business-critical systems are running operating systems that no longer receive vendor security updates. This increases exposure to known vulnerabilities and may complicate incident recovery. Management should prioritise affected systems according to business criticality and establish a funded replacement or upgrade plan.”

This demonstrates:

  • business-focused language;
  • short paragraphs;
  • risk without exaggeration;
  • clear recommended action.

A model can follow that demonstrated style for new findings.

Few-shot prompting for financial analysis

Suppose you want financial observations written consistently.

You might provide:

Example data:

Revenue: +8%

Operating margin: 12.1% → 14.0%

Net debt: R800m → R500m

Example analysis:

“Operating performance improved during the period. Revenue increased 8%, while operating margin expanded from 12.1% to 14.0%, indicating improved profitability. Net debt declined by R300 million, strengthening the balance sheet. These are positive historical developments, although they do not by themselves establish future investment performance.”

Then provide new financial data and request the same analytical style.

Few-shot prompting for research

Examples can define how you want facts, analysis and assumptions separated.

For example:

Fact:

Revenue increased from R4.1 billion to R4.6 billion.

Interpretation:

Growth appears healthy, although further analysis is required to determine whether it came from volume, pricing or acquisitions.

Unknown:

The supplied report does not provide enough segment detail to determine the primary growth driver.

This shows the model exactly how uncertainty should be represented.

Positive examples

A positive example demonstrates what the AI should do.

For instance:

“This is an example of a good executive summary.”

Positive examples are usually the simplest and most useful starting point.

Negative examples

A negative example demonstrates what should not happen.

For example:

Bad:

“This catastrophic vulnerability means attackers will definitely compromise the business.”

Why it is bad:

It exaggerates certainty and claims an outcome not supported by the evidence.

Better:

“The vulnerability increases exposure to known attack techniques and should be prioritised according to system criticality and exploitability.”

This helps define the boundary between acceptable and unacceptable output.

Use negative examples carefully

Negative examples add complexity.

Make sure they are clearly labelled.

You do not want the model confusing:

“Do this.”

with:

“Here is an example of what not to do.”

What makes a good few-shot example?

A useful example should be:

Representative

It should resemble the kinds of real inputs the model will encounter.

Correct

Do not teach the model an incorrect pattern.

Clear

The relationship between input and expected output should be obvious.

Consistent

Examples should not contradict one another.

Diverse enough

Where possible, include examples covering different realistic cases.

Poor examples teach poor patterns

This is one of the biggest risks.

Imagine you provide three examples where every high-value customer is classified as:

Priority Customer.

The model may infer that transaction value is the primary deciding factor even if your actual classification methodology is more complicated.

Examples need to reflect the real rule.

Do not accidentally introduce bias

Examples can influence the model strongly.

If all examples represent one type of customer, employee, geography or situation, the model may generalise the demonstrated pattern poorly.

For business processes, evaluate whether your examples are representative.

How many examples should you provide?

There is no universal number.

The answer depends on:

  • task complexity;
  • model capability;
  • how subtle the pattern is;
  • how many categories exist;
  • how important edge cases are; and
  • context-window constraints.

Often a small number of well-chosen examples is enough.

Start small.

Test the result.

Add examples where the model is getting the task wrong.

More examples are not automatically better

Each example consumes context.

If you add hundreds of unnecessary examples, you may:

  • increase cost;
  • increase latency;
  • bury the important instruction;
  • introduce contradictory patterns; and
  • consume context that could be used for the actual task.

The goal is:

ENOUGH EXAMPLES TO DEMONSTRATE THE PATTERN.

Choose examples strategically

Suppose you have five customer-ticket categories.

Instead of providing five almost identical examples of one category, you might include:

  • one clear example per category;
  • one ambiguous case;
  • one exception.

This gives the model more useful information.

Example ordering

For many tasks, keep examples consistently formatted.

For example:

Input: …

Output: …

Input: …

Output: …

New Input: …

Output:

Consistency makes the intended pattern easier to identify.

Use separators

For complex prompts, separate examples clearly.

You could use:

--- EXAMPLE 1 ---

or XML-style tags:

<example>...</example>

or headings.

The exact format is less important than clarity.

Few-shot prompting and hallucinations

Examples can improve format and behaviour.

They do not guarantee factual accuracy.

If your example contains fabricated facts, the model may reproduce that pattern.

If your new task requires current information, the model still needs access to appropriate sources.

Examples guide behaviour.

They are not a replacement for evidence.

Few-shot prompting vs retrieval

These solve different problems.

Few-shot prompting:

“Here are examples of how I want you to perform the task.”

Retrieval:

“Here is the factual information relevant to this particular request.”

You can use both together.

Example: combining retrieval and examples

Imagine an AI governance-reporting system.

You provide:

Retrieved evidence:

The current assessment findings.

Few-shot examples:

Three approved examples of how risk findings should be written.

Instructions:

Generate the new report using the evidence while following the demonstrated style.

Now the AI has both:

WHAT IS TRUE

and:

HOW TO PRESENT IT.

Few-shot prompting vs fine-tuning

These are also different.

Few-shot prompting provides examples during inference.

Fine-tuning adapts the model through additional training.

Few-Shot PromptingFine-Tuning
Examples included in promptExamples used in additional training
Fast to changeRequires training process
Consumes contextBehaviour becomes part of adapted model
Good for experimentationUseful for certain repeatable specialised tasks

Start with prompting before fine-tuning

For many applications, it makes sense to first test whether strong instructions, examples and retrieval can achieve the required performance.

Fine-tuning adds additional complexity.

It should solve a specific problem rather than being used simply because it sounds more advanced.

Few-shot prompting in teams

Example libraries can become extremely useful inside organisations.

Suppose your team regularly creates:

  • risk findings;
  • customer reports;
  • executive summaries;
  • support responses;
  • proposals;
  • incident reports.

You can maintain a small set of approved high-quality examples.

AI workflows can use those examples to help standardise output.

Examples can represent quality standards

Instead of merely documenting:

“Reports should be professional.”

you can show:

three approved reports.

The examples become an operational demonstration of the standard.

Be careful with confidential examples

Examples may contain sensitive information.

Before inserting previous customer documents or internal work into an AI tool, consider:

  • privacy;
  • confidentiality;
  • data-handling policies;
  • contractual requirements;
  • permissions; and
  • whether the information needs to be anonymised.

Good prompting does not override good information security.

Use synthetic examples where appropriate

If real data is sensitive, you can sometimes create artificial examples that demonstrate the required pattern without exposing actual customer information.

For example:

Customer: Example Manufacturing Ltd

Finding: Unsupported systems

rather than using the name and technical details of a real customer.

A reusable few-shot template

You can use this structure:

TASK

[Explain what the AI should do.]

RULES

[Define important constraints.]

EXAMPLE 1

Input: [example input]

Output: [ideal output]

EXAMPLE 2

Input: [example input]

Output: [ideal output]

EXAMPLE 3

Input: [example input]

Output: [ideal output]

NEW INPUT

[Insert new task.]

REQUIRED OUTPUT

Follow the demonstrated pattern without copying example wording.

Practical example: support-ticket classification

Task:

Classify support requests into Access, Hardware, Software, Network or Security.

Examples:

“I forgot my password.” → Access

“My second monitor no longer switches on.” → Hardware

“Excel crashes every time I open one specific workbook.” → Software

“I cannot access any websites from the office.” → Network

“I clicked a link in a suspicious email.” → Security

New input:

“My laptop says my account has been locked.”

The model now has concrete examples of the taxonomy.

Practical example: article introductions

Suppose you want all articles to start with:

  • a familiar problem;
  • a simple observation;
  • a core question;
  • then the article’s objective.

Instead of describing this repeatedly, maintain several high-quality examples of introductions.

Your prompt could say:

“Use the examples to understand the preferred structure of our article introductions. Begin with a relatable problem or observation, introduce the central question and then explain what the reader will learn. Do not copy any sentences from the examples.”

Test examples before standardising them

Do not put a prompt into production simply because it works once.

Test it against:

  • normal examples;
  • edge cases;
  • ambiguous inputs;
  • long inputs;
  • short inputs;
  • missing information.

Then improve the examples based on failures.

The SHOW framework

Here is an original simple checklist for creating few-shot examples.

S — Similar

Are the examples similar to the real task?

H — High quality

Are the demonstrated outputs actually correct and desirable?

O — Outliers

Have you demonstrated important exceptions or edge cases?

W — Well structured

Are the examples consistently formatted and easy to interpret?

The SHOW framework is an original educational framework created for this learning series, not an industry standard.

Common few-shot prompting mistakes

Mistake 1 — Bad examples

The AI learns the wrong pattern.

Mistake 2 — Contradictory examples

Similar inputs receive different outputs without an explanation.

Mistake 3 — Too many examples

The prompt becomes expensive and difficult to maintain.

Mistake 4 — Examples that are too similar

The model does not learn how to handle realistic variation.

Mistake 5 — No edge cases

The prompt works on easy inputs but fails on ambiguous situations.

Mistake 6 — Sensitive information

Real customer or confidential data is unnecessarily placed into examples.

Mistake 7 — Assuming examples guarantee truth

They guide behaviour, not factual verification.

When should you use few-shot prompting?

Few-shot prompting is particularly useful when:

  • output style matters;
  • you have custom categories;
  • the correct format is hard to describe;
  • the task has edge cases;
  • you want repeatable output;
  • you have good examples of successful work.

When may it be unnecessary?

Examples may not add much value when:

  • the task is extremely simple;
  • the model already handles it reliably;
  • there is no unusual output pattern;
  • the examples consume more context than they are worth.

Build examples from failures

One of the best ways to improve a prompt is to look at where it fails.

Suppose your model repeatedly misclassifies billing complaints as general support.

Add two high-quality examples demonstrating the difference.

Your few-shot library should evolve based on real mistakes.

Frequently asked questions

What is few-shot prompting?

Few-shot prompting is a technique where a small number of input-output examples are included in the prompt to demonstrate the pattern the AI should follow.

What is zero-shot prompting?

Zero-shot prompting provides instructions without any examples.

What is one-shot prompting?

One-shot prompting provides one example before the new task.

How many examples should I use?

There is no fixed number. Start with a small set of representative, high-quality examples and add more only when they address real failure cases.

Does few-shot prompting train the model?

No. The examples are normally used as context during inference rather than permanently retraining the underlying model.

What tasks benefit from examples?

Classification, extraction, writing style, structured reporting and tasks with custom organisational standards often benefit significantly.

Should I include bad examples?

Negative examples can be useful if they are clearly labelled and explain what is wrong, but positive examples are usually the simplest starting point.

Can examples reduce hallucinations?

Examples can improve output structure and behaviour, but they do not replace reliable source data or factual verification.

Is few-shot prompting the same as fine-tuning?

No. Few-shot examples are provided during inference. Fine-tuning changes model behaviour through additional training.

Can examples contain confidential data?

They can, but sensitive information should only be used where the AI service and organisational policy permit it. Anonymised or synthetic examples may be safer.

Key takeaways

  • Few-shot prompting teaches a pattern by providing examples inside the prompt.
  • Zero-shot uses no examples, one-shot uses one and few-shot uses several.
  • Examples are particularly valuable when style, format or classification rules matter.
  • Good examples reduce ambiguity.
  • Examples should be representative, correct, consistent and diverse.
  • Edge cases can be more valuable than several nearly identical examples.
  • More examples are not automatically better.
  • Examples consume context and can increase cost.
  • Poor examples can teach poor patterns or introduce bias.
  • Few-shot prompting can work together with retrieval and structured-output controls.
  • Few-shot prompting is not the same as fine-tuning.
  • Build your example library using lessons from real failures.

Continue the AI Prompting learning path

You now know how to describe the result you want and how to demonstrate it using examples.

But there is another important lesson:

Your first prompt does not need to be perfect.

Some of the best AI work comes from reviewing the first response, identifying what is missing and progressively improving the result.

This is called iterative prompting.

Next: Iterative Prompting — Why Your First Prompt Shouldn’t Be Your Last →