Few-Shot Prompting and Examples

Compare zero-shot and few-shot prompting, and guide classification with clear rules and input-output examples.

🎯 Introduction

Suppose your store's support system classifies customer messages as inquiry, complaint, or after-sales support.

“Is this available in XL?” is an inquiry. “The clothing does not fit; I want an exchange” is after-sales support.

You can define the categories in words. But definitions alone may be difficult to apply when categories overlap.

Providing a few already classified messages can help the model classify new ones.

This article covers zero-shot and few-shot prompting and how to choose useful examples.


🧱 Zero-Shot and Few-Shot Prompting

First, define rules used throughout the examples and exercises:

CategoryRule
InquiryPre-purchase questions about products, such as size, color, or availability
ComplaintDissatisfaction with service without requesting help for a purchased product
After-sales supportPost-purchase requests for returns, exchanges, or help with received products

These are demonstration rules. Real businesses can use different categories, but decisions under the same rules should remain consistent.

Zero-Shot: Instructions Without Examples

Zero-shot prompting specifies a task without completed input-output examples.

For example:

Classify the customer message as Inquiry, Complaint, or After-sales support.

Rules:
Inquiry: Pre-purchase questions about product information.
Complaint: Dissatisfaction with service without requesting help for a purchased product.
After-sales support: Post-purchase returns, exchanges, or issues with received products.

Return only the category name, without explanation.

Customer message: The clothing does not fit. I want an exchange.
Category:

Under our rules, this is After-sales support because the customer explicitly requests an exchange.

The prompt defines classification but provides no completed message-category pairs, so it is zero-shot.

Few-Shot: Adding a Few Examples

Few-shot prompting adds a small number of completed input-output examples alongside instructions.

Keep the rules and add three examples:

Classify the customer message as Inquiry, Complaint, or After-sales support.

Rules:
Inquiry: Pre-purchase questions about product information.
Complaint: Dissatisfaction with service without requesting help for a purchased product.
After-sales support: Post-purchase returns, exchanges, or issues with received products.

Return only the category name, without explanation.

Reference examples:

Customer message: Is this clothing available in XL?
Category: Inquiry

Customer message: Support replies too slowly. The experience is terrible.
Category: Complaint

Customer message: The clothing arrived torn. I want to return it.
Category: After-sales support

Now classify:
Customer message: The clothing does not fit. I want an exchange.
Category:

The task, rules, and target message are unchanged; only three examples have been added.

Each demonstrates a customer message and its expected category, making both judgment and output format more concrete.

The central difference:

  • Zero-shot: instructions and requirements without completed examples.
  • Few-shot: instructions and requirements plus a few completed examples.

Few-shot prompting does not retrain the model. Examples are reference content for the current request, not permanent changes to trained parameters.


🧱 Choosing Examples

Useful few-shot prompting depends on suitable examples, rather than adding examples arbitrarily.

1. Cover the Relevant Categories

Consider:

Customer message: How much does this clothing cost?
Category: Inquiry

Customer message: Is it available in black?
Category: Inquiry

Customer message: Is it in stock?
Category: Inquiry

All examples are inquiries. They do not demonstrate complaints or after-sales support, making the other categories harder to distinguish by example.

A better starting point is one representative example per category.

2. Follow the Classification Rules

This example is wrong:

Customer message: The clothing does not fit. I want an exchange.
Category: Inquiry

An explicit exchange request belongs to after-sales support under our rules.

Incorrect examples provide conflicting guidance. Check labels before adding examples.

3. Keep Input and Output Formats Consistent

The examples consistently use:

Customer message: ...
Category: ...

Maintain that format so the model can distinguish input from expected output.

4. Clarify Ambiguous Rules First

Consider:

I would like to know how refunds work.

Different stores might classify this differently. Do not assign a label based only on intuition.

If the business classifies all refund questions about purchased orders as after-sales support, state that rule first, then provide matching examples.

Examples clarify rules; they cannot replace business criteria that have not been defined.


⚠️ Problems Examples Can Introduce

Few-shot is not always better than zero-shot. Poor examples can hurt results.

For example:

  • Only one category is represented: the model may favor it and struggle with others.
  • Labels conflict with rules: it may imitate incorrect decisions.
  • Examples lack variety: short, simple messages may offer limited help for longer messages with multiple intents.

Examples also consume tokens. Including many in every request increases input length and may increase cost.

Start with a few correct, representative examples, then test new messages absent from the examples.

If results violate business rules, check unclear rules or unsuitable examples before adding more.


💡 When Is Few-Shot Prompting Useful?

If a clear zero-shot prompt already works consistently, examples may be unnecessary.

Try few-shot prompting when the model struggles with a decision criterion or needs to imitate a specific style or format.

For classification, test a zero-shot prompt on real messages first. If ambiguous messages are repeatedly misclassified, add examples consistent with the rules and compare both prompts on the same test messages.

Testing establishes whether the examples help; merely adding them does not.


❓ Knowledge Check

Q1: Does few-shot prompting train the model?

No. It supplies reference examples in the current prompt without retraining or guaranteeing permanent memory.

Q2: Do more examples guarantee higher accuracy?

No. Correctness, coverage, and model capability matter. Repeated or incorrect examples may not help.

Q3: Should a few-shot prompt still include classification rules?

When clear business criteria exist, state them. Examples should clarify those criteria rather than force the model to infer them from a few cases.


🧪 Exercise

Classify product reviews as positive, negative, or neutral.

Define the rules:

  • Positive: mainly expresses satisfaction or approval.
  • Negative: mainly expresses dissatisfaction; if a review includes both strengths and serious problems, prioritize negative.
  • Neutral: mainly states facts without clear satisfaction or dissatisfaction.

Complete these tasks:

  1. Write a zero-shot prompt with the task, rules, and category-only output requirement, without examples.
  2. Create a few-shot version retaining the same task and rules and adding one correctly labeled review per category.
  3. Test the same new review in both: “Shipping was okay, but the packaging was badly damaged.” Record whether outputs follow the rules.
  4. Compare results: if both return “Negative,” can you conclude that few-shot is always better? Why?

Success criteria: Both versions share the same rules; few-shot adds three correct input-output examples. The test review is negative under these rules. One correct answer from each cannot establish that few-shot is better; compare more reviews absent from the examples.


🎉 Congratulations! You understand zero-shot and few-shot prompting, selecting examples according to business rules, and testing their value. Next, we will constrain output formats and break down complex tasks.