Skip to content
Gab AI

5 min reading · Practice at your pace

Few-Shot Prompting: Zero, One and Multiple Examples

Show AI the pattern you want with example inputs and outputs. Compare zero-shot, one-shot and few-shot prompts, then practice preserving the same answers in a new format.

What is few-shot prompting?

Show example inputs and outputs in the prompt so the model can follow a format or decision pattern. Zero-shot supplies no worked examples; one-shot supplies one; few-shot supplies several. This is context within a request, distinct from changing model weights through fine-tuning.

Three prompts, the same checked result

Three separate Gab Temporary Chats used Arya with the same rules, records and requested format. Only the number of demonstrations changed: zero, one or three. All returned these exact four lines.

Actual result returned in all three chats
Text
A | READY
B | MISSING
C | CONFLICT
D | CONFLICT

What changed in this small comparison

What changed in this small comparison
Item
Details
Zero-shot0 demonstrations; all four labels and the requested line format matched the author-defined rules.
One-shot1 demonstration; all four labels and the requested line format matched the author-defined rules.
Few-shot3 demonstrations; all four labels and the requested line format matched the author-defined rules.

Check the rules and held-out records

READY means room and start time are both supplied. MISSING means at least one is absent. CONFLICT means a field has competing values and takes priority over MISSING. The test records were not copied from the demonstrations.

Records used in each request
Text
A: room Cedar; start 09:15.
B: room Maple; start not supplied.
C: room Ash; starts 09:15 and 10:30.
D: room not supplied; starts 09:15 and 10:30.

  • A has a room and one time: READY.
  • B has no time: MISSING.
  • C has two competing times: CONFLICT.
  • D has a missing room and competing times: CONFLICT takes priority.
Read the zero-shot request

The task, rules and held-out records stayed the same.

request
Text
Use only these workshop records. Do not search the web or use account memories.
Labels: READY = room and start time both supplied; MISSING = at least one of those fields is absent; CONFLICT = a field has competing values. Apply CONFLICT before MISSING. Do not infer a missing field.
Return exactly id | label, one line per record, in the supplied order. No heading, Markdown table, explanations or extra text.

Records to classify:
A: room Cedar; start 09:15.
B: room Maple; start not supplied.
C: room Ash; starts 09:15 and 10:30.
D: room not supplied; starts 09:15 and 10:30.

Read the one-shot request

The task, rules and held-out records stayed the same.

request
Text
Use only these workshop records. Do not search the web or use account memories.
Labels: READY = room and start time both supplied; MISSING = at least one of those fields is absent; CONFLICT = a field has competing values. Apply CONFLICT before MISSING. Do not infer a missing field.
Return exactly id | label, one line per record, in the supplied order. No heading, Markdown table, explanations or extra text.

Examples:
Input: X: room Birch; start 11:00.
Output: X | READY

Records to classify:
A: room Cedar; start 09:15.
B: room Maple; start not supplied.
C: room Ash; starts 09:15 and 10:30.
D: room not supplied; starts 09:15 and 10:30.

Read the few-shot request

The task, rules and held-out records stayed the same.

request
Text
Use only these workshop records. Do not search the web or use account memories.
Labels: READY = room and start time both supplied; MISSING = at least one of those fields is absent; CONFLICT = a field has competing values. Apply CONFLICT before MISSING. Do not infer a missing field.
Return exactly id | label, one line per record, in the supplied order. No heading, Markdown table, explanations or extra text.

Examples:
Input: X: room Birch; start 11:00.
Output: X | READY

Input: Y: room Oak; start not supplied.
Output: Y | MISSING

Input: Z: room Pine; starts 08:00 and 08:30.
Output: Z | CONFLICT

Records to classify:
A: room Cedar; start 09:15.
B: room Maple; start not supplied.
C: room Ash; starts 09:15 and 10:30.
D: room not supplied; starts 09:15 and 10:30.

Choose examples that clarify the task

Use representative inputs, correct outputs and consistent labels. Include a missing-information or edge case when it changes the decision. In this fully specified task, extra examples produced no observable improvement; one run per condition does not establish which method is best for other tasks or models.

Show a writing style and format

These practice examples turn rough event notes into a plain, two-line notice. They also show how to handle a missing venue. Use demonstrations when showing the pattern is clearer than explaining it.

few-shot writing prompt to try
Text
Write a two-line event notice in plain language. Follow the examples, preserve the supplied facts and do not invent a venue.

Example 1
Input: Repair café. Thursday at 18:00. Venue: Oak Hall.
Output:
Repair café meets on Thursday at 18:00.
Venue: Oak Hall.

Example 2
Input: Garden club. Sunday at 10:00. Venue not supplied.
Output:
Garden club meets on Sunday at 10:00.
Venue not supplied.

New input: Book swap. Saturday at 11:00. Venue: Pine Room.
Return only the two-line notice.

  • Check that the new notice keeps Book swap, Saturday, 11:00 and Pine Room.
  • Check the two-line format and plain wording; the demonstrations are not captured model outputs.
  • Try a new input without a venue and check that the answer identifies the missing venue instead of inventing one.

When examples contradict the rules

A conflicting demonstration can make your intended pattern unclear. Correct or remove it before adding more examples.

An incorrect example — do not reuse
Text
Input: room Pine; starts 08:00 and 08:30.
Incorrect output: READY
Correction: CONFLICT, because two start times are supplied.

Revise the format while preserving checked values

In the few-shot conversation, a follow-up changed only the requested output format. The actual response became valid JSON and kept all four labels and their order.

Actual format revision
JSON
[
{"id": "A", "label": "READY"},
{"id": "B", "label": "MISSING"},
{"id": "C", "label": "CONFLICT"},
{"id": "D", "label": "CONFLICT"}
]

Read the revision request

Captured follow-up to the few-shot answer.

Revision request
Text
Change only the output format to a JSON array of objects with keys "id" and "label". Keep every existing label and the A, B, C, D record order unchanged. Use only the records already supplied. Return the JSON array alone, without a code fence, heading or explanation. Do not search or use account memories.

Check the pattern on new inputs

Prepare the expected labels from the rules before running the task. Compare every record, edge case and output field, then check the complete format revision. Keep examples relevant and consistent.

Few-shot prompting questions

Choose the smallest useful set of demonstrations and test the result.

How many examples should I include?

Start with a relevant example, add missing patterns or edge cases, and compare the result on new inputs. There is no universal best count; all three conditions worked equally on this small task.

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

No. The demonstrations are supplied as request context. Fine-tuning changes model parameters through a separate training process; prompt examples do not establish what a provider retains or later uses.

Why does AI copy the wrong pattern?

Check whether your examples contradict the rules, use inconsistent labels or omit a relevant edge case. Correct the examples and test new records instead of judging only the demonstration inputs.

A moment to put it together.

Record D has no room and two competing times. Which label follows the supplied rules?

What did the three actual runs establish?

Your turn

Show the pattern, then change the format.

Use the complete classification request below. Check READY, MISSING and CONFLICT against the supplied rules before requesting JSON.

Review your draft

Write a draft and review the checklist.

Your draft saves in this browser. You can leave and come back.

Try the prompt in Chat

Copy the prompt, open Chat and paste it into the composer. Read the answer beside the supplied facts before requesting the revision below.

These buttons open the product and copy your draft. You choose the mode and send the request yourself.

Open Chat

Make one change and check the whole result

Review the first answer, then send this follow-up in the same conversation.

Focused practice revision
Text
Change only the output format to a JSON array of objects with keys "id" and "label". Keep every existing label and the A, B, C, D record order unchanged. Use only the records already supplied. Return the JSON array alone, without a code fence, heading or explanation. Do not search or use account memories.

Check that the requested change happened and the correct facts, format and missing details survived. For a file, open the revised artifact and inspect nearby paragraphs or formulas too.