Guide

How to Use Examples in Prompts Without Teaching Mistakes

Use examples in AI prompts to improve consistency while avoiding copied errors, narrow patterns, irrelevant details, and misleading few-shot demonstrations.

Examples can show a model the pattern you want more precisely than a long description. They are especially useful for classification, extraction, transformation, tone matching, and structured output. They can also transmit errors, bias, irrelevant wording, and accidental shortcuts.

When examples help#

Use examples when:

  • categories are difficult to define in words alone;
  • the output has a specific structure or labeling convention;
  • acceptable and unacceptable cases are close together;
  • style consistency matters;
  • a transformation must preserve some features and change others;
  • prior attempts show the model repeatedly misreading a requirement.

Do not add examples merely to make a prompt look advanced. A clear zero-shot instruction is often shorter and easier to maintain.

Example anatomy#

A useful example labels the input, the desired output, and the feature being demonstrated.

Prompt template
Example input:
The setup was simple, but exports failed twice and support replied the next day.

Example output:
Sentiment: mixed
Evidence: “setup was simple” is positive; “exports failed twice” is negative; support response is neutral-to-negative.

Pattern to follow:
Choose one label and cite the phrases that justify it.

The explanation makes the pattern visible instead of relying on the model to infer why the label was chosen.

Separate instructions from examples#

Prompt template
Instructions:
Classify each query by its dominant search intent. Use one label: informational, commercial, transactional, or navigational. If evidence is mixed, choose the intent most likely to shape the expected page.

<EXAMPLES>
Input: best accounting software for freelancers
Output: commercial
Reason: the user is comparing options before a purchase decision.

Input: QuickBooks login
Output: navigational
Reason: the user wants a specific destination.
</EXAMPLES>

Now classify:
[QUERY]

Clear separators reduce confusion between examples and the new task.

Choose diverse examples#

Examples should cover the real decision boundary, not repeat the easiest case. For classification, include near-neighbors that could be confused. For writing, include more than one length or situation when variation is expected.

A narrow set of examples may teach an accidental rule. If every positive example contains the word “excellent,” the model may associate that word with the category rather than the underlying meaning.

Keep examples internally consistent#

Check that labels, explanations, formatting, and constraints agree. Models can copy punctuation, typos, unsupported claims, and inconsistent field names.

Before using an example, ask:

  • Is the output actually acceptable?
  • Does it follow the current instructions?
  • Is the label defensible?
  • Does it contain private or outdated information?
  • Could the model copy a value that should be variable?

Use counterexamples carefully#

A counterexample can clarify a boundary.

Prompt template
Do not classify a page as transactional merely because it mentions a product. Example: “how does password-manager encryption work?” remains informational because the user is learning, not trying to buy or sign in.

Do not overload the prompt with many negative examples. State the rule first, then add the smallest counterexample that resolves ambiguity.

Examples versus reference content#

An example demonstrates how to respond. Reference content supplies facts for the current task. Label them separately.

Prompt template
<STYLE_EXAMPLE>
[Approved example showing tone and format]
</STYLE_EXAMPLE>

<SOURCE_FACTS>
[Facts that may be used in this output]
</SOURCE_FACTS>

Without this separation, the model may copy facts from the style example into the new output.

Before and after: grammar editing#

Instruction only

Prompt template
Correct the grammar without changing the meaning.

Instruction with example

Prompt template
Correct grammar, punctuation, and obvious usage errors. Preserve the writer's meaning, terminology, paragraph order, and level of formality. Do not rewrite for style unless required for correctness.

Example input: Neither of the reports were ready, and the team don't know why.
Example output: Neither of the reports was ready, and the team does not know why.
Example note: Agreement was corrected; tone and meaning were preserved.

Now edit:
[TEXT]

The example demonstrates the permitted degree of change.

Before and after: story style#

A style example should identify transferable traits rather than asking the model to imitate a living author or copy distinctive passages.

Prompt template
Use the example only for these traits: short sensory sentences, close third-person perspective, restrained dialogue, and an unresolved final image. Do not reuse names, events, metaphors, or sentences from the example.

Test method#

  1. Build a small evaluation set that includes normal, edge, and ambiguous inputs.
  2. Run the prompt without examples and record failures.
  3. Add the smallest useful example set.
  4. Check whether the examples fix the intended failure.
  5. Check for new copying, bias, or overfitting.
  6. Remove any example that does not improve a defined outcome.

How the Prompt Checker uses examples#

The checker looks for surface cues that examples are present. It cannot judge whether an example is correct, representative, safe, or useful.

Example checklist#

  • The instruction works as a rule before examples are added.
  • Each example demonstrates a specific boundary or pattern.
  • Examples are accurate and internally consistent.
  • Variable values are not likely to be copied accidentally.
  • Sensitive and proprietary data has been removed.
  • The set includes relevant diversity and edge cases.
  • Testing compares results with and without examples.

FAQ#

How many examples should I use?

Use the smallest set that resolves the observed ambiguity. More examples increase prompt length and maintenance cost.

Should examples include explanations?

Include short reasoning when the label or transformation boundary is not obvious. Do not request hidden chain-of-thought; an observable rationale or evidence field is enough.

Can examples make output worse?

Yes. Incorrect, narrow, or irrelevant examples can anchor the model to the wrong pattern.