Example-Based Learning (Few-Shot Prompting)

Learning Outcome

4

Differentiate between zero-shot, one-shot, and few-shot prompting.

3

Apply example-based prompting to guide AI toward a specific style or format.

2

Identify when to use examples instead of pure instructions.

1

Understand what Example-Based (Few-Shot) Prompting is and how it works.

Before we begin — let's recall

Prompt Components

Instruction, Context, Role, Format, Constraints, and Examples.

Instruction-Based Prompting

direct commands work well for simple, well-defined tasks.

Direct instructions alone sometimes aren't enough — especially when the style or pattern you want is hard to describe in words. → This is where Example-Based Learning comes in.

Imagine you visit a tailor and say,

The tailor has no idea what "nice" means to you — casual or formal? Slim fit or loose? Which color?

Now imagine instead you bring a sample shirt and say,

The tailor instantly understands the cut, style, and fit — because you showed, instead of just telling.

Example-Based Learning works the same way. Instead of only describing what you want, you show the AI one or more examples of the exact style, format, or pattern you expect — and it follows that pattern for new inputs.

Think About It

 Previously, we imagined a tailor — struggling with a vague request, but instantly understanding once shown a sample shirt to copy.

Can words alone always fully describe the exact style, tone, or format you have in mind?

A small thought before we go technical

Expected Answer

NO

Just like a tailor learns from a sample, AI performs better when shown examples.

Now, let's explore how Example-Based Learning works.

What is Example-Based Learning?

--- Definition ---

Example-Based Learning (also called Few-Shot Prompting) is a technique where you provide the AI with one or more sample input-output pairs within the prompt, so it can recognize the pattern and apply it to a new input.

 

Instead of relying purely on instructions, you demonstrate the expected style, tone, or structure.

Why it matters:

It's far more effective than instructions alone when the desired output has a specific "feel" that's hard to describe in words.

It significantly improves consistency across multiple AI-generated outputs.

It reduces back-and-forth corrections by showing the target format upfront.

Real-Life Examples

Showing AI 2 sample product taglines to generate more in the same punchy style.

Providing a sample customer support reply so the AI matches the company's tone in future replies.

 Zero-Shot Prompting

Zero-Shot means giving the AI a task with no examples at all — relying purely on the instruction.

 

Works well for simple, common tasks the AI already understands well.

One-Shot Prompting

One-Shot means giving the AI exactly one example to establish the expected pattern before asking for a new output.

 

Useful when a task has a specific style that's clearer to show than describe.

Few-Shot Prompting

Few-Shot means giving the AI multiple examples (typically 2-5) to reinforce a pattern more strongly before generating new output.

 

More examples generally lead to more consistent, reliable pattern-matching — especially for nuanced styles.

Structuring Examples Effectively

Good examples should be:

Consistent in format with each other

Representative of the range you expect (not all identical)

Clearly separated from the new input, so the AI doesn't confuse sample and task

Zero-Shot vs. One-Shot vs. Few-Shot (Comparison)

How Example-Based Learning Works (Core Mechanism)

Applications of Example-Based Learning

Daily Life Applications

Summary

4

Ward’s method keeps clusters compact.

3

Cut the tree to find optimal clusters.

2

Dendrogram shows merge history and distances.

1

Bottom-up clustering (each point → one cluster → merge).

Quiz

What does dendrogram height represent?

A. Number of data points

B. Distance between clusters

C. Processing time

D. Accuracy

Quiz-Answer

What does dendrogram height represent?

A. Number of data points

B. Distance between clusters

C. Processing time

D. Accuracy

Copy of Copy of Template

By Content ITV

Copy of Copy of Template

  • 43