Few-Shot Prompting: Teach the Pattern With Examples

Show an assistant a few input-and-answer examples to make the expected pattern clear. Learn which examples help, how to test them, and what they cannot guarantee.

Updated 5 min read

Few-shot prompting means including a few examples of inputs and good answers in your request, so an AI can follow the demonstrated pattern on a new input. It is useful when a written rule leaves room for interpretation, such as the right structure for a task summary or the difference between an observation and a decision.

Tools like fenbs can keep the approved examples with reusable prompts, so different connected assistants receive the same starting material. You still need clear instructions and a check of the result; a convincing example does not make every later answer correct.

What does an example add to an instruction?

An instruction states what you want. An example demonstrates how to apply it. “Write a concise update” leaves the length, order, and level of detail open; a sample update can show that the current state comes first, followed by the next action and anything unresolved.

Google’s few-shot guidance (opens in a new tab) describes examples as a way to steer patterns such as formatting and phrasing. It also recommends explicit instructions, because examples alone can teach a pattern you did not intend. Treat the instruction and the demonstration as a pair.

Suppose you want short handoff notes. Your instruction says to keep confirmed actions separate from suggestions. A sample with a suggested deadline makes the distinction visible: it labels the deadline as unconfirmed instead of presenting it as an agreement.

Prompt approachWhat it providesWhen to try it
No examplesA task description and explicit requirements.The task is clear and a simple instruction already passes your checks.
One exampleA concrete demonstration of the answer shape.You need to clarify a format or show a short voice sample.
Several examplesDifferent cases that demonstrate the same rule.The distinction depends on varied inputs or exceptions.

How do you write a few-shot prompt?

Start by naming the job and its boundaries. Then label each example’s input and expected output, and put the new input in its own clearly marked area. Keeping these parts separate makes it easier for you to review the prompt and change one example without altering the task.

Example: separate confirmed work from suggestions
Task: Turn a work note into a handoff. Use Status and Next step.
Only call work complete when the note confirms completion.
Do not turn a proposed date into an approved deadline.

Example 1 input: The draft is approved. Mia will send it tomorrow.
Example 1 output:
Status: Draft approved.
Next step: Mia to send it tomorrow.

Example 2 input: The draft is ready for review. Friday was suggested.
Example 2 output:
Status: Draft awaiting review.
Next step: Confirm the review date; Friday is a suggestion.

New input: [paste the new work note here]

These are invented samples, not records of real approvals. The first shows an action the source supports; the second shows what to do when the source leaves a question open. Both use the same labels, but neither gives the assistant permission to reuse the names or dates for a different note.

Before running it, read only the instruction and the examples. Do they agree? If the instruction says never guess a deadline but one sample includes an invented date, fix the sample. A contradiction inside the demonstration makes a failed answer harder to diagnose.

Which examples should you include?

Choose samples because they teach a distinction, not because they are your best-looking outputs. Include a straightforward case, a case with missing information, and a case that could easily be misread. The right mix depends on the mistakes you actually need to prevent.

Anthropic’s prompting guidance (opens in a new tab) recommends relevant, varied, clearly structured examples. For a work prompt, that means examples resembling your task while changing the details enough that a repeated name, topic, or conclusion does not become an accidental rule.

  • Match the real input: a messy note needs a messy-note example, not only a polished paragraph.
  • Show the desired answer: include the complete output you would accept, with the labels you need.
  • Vary the facts: change owners, dates, and the order in which information appears.
  • Demonstrate uncertainty: show how to respond when the input cannot support a definite answer.
  • Keep irrelevant detail out: a sample should teach the rule without burying it in background.

Start small and add a sample when it addresses a specific failure. More examples mean more material to maintain and inspect. If several examples teach the same easy case, replacing one with a useful exception can be more informative than adding another nearly identical answer.

How do you test whether the pattern transfers?

Test the prompt on inputs that are not in the examples. Otherwise you may only learn that the assistant can repeat a demonstration. Write the expected properties before you run the test, so you do not quietly lower the standard after reading a fluent answer.

  1. Save a version of the instruction without examples and run it on your test inputs.
  2. Run the version with examples on the same inputs using the same assistant.
  3. Check facts, format, and treatment of missing information separately.
  4. Inspect any answer that copied a sample detail or applied a rule to the wrong case.
  5. Revise one example or instruction, then rerun the full set to check for new mistakes.

For the handoff prompt, try a note with two proposed dates and another with no next action. The answer should report uncertainty without choosing a date or owner for convenience. Also try a confirmed deadline, because a fix that labels every date as uncertain would create a different error.

Save the accepted pattern and the test lesson in fenbs Skills and prompts and Lessons learned. That preserves why an example belongs in the prompt, so a later assistant can maintain it without guessing at your intention.

What can go wrong with example-based prompts?

A sample can smuggle in assumptions. If every example ends with approval, the prompt may encourage approval even when a real input describes a disagreement. If every missing detail gets filled in, you have demonstrated guessing while asking for accuracy.

Keep example material separate from current evidence. A sample refund response might demonstrate sentence structure, but its terms are not the current refund policy. Supply approved facts independently and tell the assistant to use those facts for the new response.

Examples in a prompt also do not permanently train the underlying model. Include them again when the next session needs them, or keep them in a supported reusable instruction workflow. The Claude prompting guide covers that assistant’s broader prompting practices.

How fenbs helps

Make approved examples reusable

Save your instruction and its accepted examples together in fenbs Skills and prompts. Add a lesson when a test reveals an unintended pattern, with the specific change that corrected it. A connected assistant can read the same material when you start the next work session.

Create a free account

Free for one person · No credit card · Works with Claude, ChatGPT, Cursor and more

How to do this with fenbs

  1. Create a free account and add the project where the prompt will be used.
  2. Save the task instruction and approved examples as a Skills and prompts entry with a clear name and intended use.
  3. Add a task for testing the prompt. Put the checks in its plan and record which cases passed or failed.
  4. Record the person’s approved behavior boundaries in Decisions and rules, and keep sample facts clearly separate from live project notes.
  5. Connect your supported AI app through Integrations, ask it to read the relevant prompt, and save progress after testing.

fenbs stores the work record and reusable material; it does not automatically insert examples into every message or run an evaluation for you. If you only need a one-time demonstration, pasting a short prompt may be enough. A shared record helps when the examples need ongoing review or use across supported assistants.

Make the first entry small: one job, a few meaningful examples, and a short checklist. Try a fresh input before expanding it. You can find related ways to build reusable instructions in the AI prompts library.

Questions people ask.

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

No. Few-shot prompting supplies examples as part of the information for a request. Fine-tuning changes a model through a separate training process; adding examples to a chat does not perform that process.

Is there a fixed number of examples I should use?

No. Start with enough examples to demonstrate the important distinctions, then test on unfamiliar inputs. Add or replace an example when it addresses a real failure.

Can I use invented examples?

Yes, when they are clearly samples and accurately demonstrate the behavior you want. Keep their names, dates, and other invented facts separate from real project evidence.

Should I include bad answers as examples?

Usually start with accepted answers. If you include a bad answer to explain a common mistake, label it clearly and show the corrected answer so the desired behavior is unambiguous.

Start with one thing.

Free for one person · No credit card · Works with Claude, ChatGPT, Cursor and more

There is nothing to set up first. Write one line and you’ve started.