Examples: Zero-, One-, and Few-Shot
Use demonstrations to steer behavior, balancing exemplar quality, order effects, and when to skip examples entirely.
Content
Counterexamples for Boundaries
Versions:
Watch & Learn
AI-discovered learning video
Sign in to watch the learning video for this topic.
Counterexamples for Boundaries — The Art of Saying Nope So the Model Knows Yes
You taught the model what to do. Now teach it what not to do. Otherwise it will improvise, and improv is a dangerous roommate.
You already know how to pick high quality exemplars and how to ground the model with structured context blocks and delimiters. Now we sharpen the fence. This piece builds on selecting exemplars and supplying context by showing how counterexamples define boundaries — not just help the model learn the right answers, but also learn what counts as wrong, edge, or forbidden.
Why counterexamples matter (and why they are underused)
- Positive exemplars teach the model the target behavior. But positive examples alone often leave the space of failure ambiguous.
- Counterexamples place a fence around the behavior. They show the model the edge cases, the near-misses, and the absolutely unacceptable outputs.
Think of exemplars as a cozy house you want the model to live in. Counterexamples are the clearly labeled 'Do not enter' signs on the porch, the moat, and that one guy screaming through a megaphone. Without them the model wanders out and invents neighbors.
What is a counterexample, exactly?
Counterexample: an exemplar that demonstrates an incorrect, undesirable, or out-of-scope response — ideally a near-miss that clarifies boundaries.
Types:
- Explicit negative: a clear wrong answer with a negative label (eg, Label: Incorrect). Useful for classification boundaries.
- Near-miss: almost-correct but violates a critical constraint. Highest teaching value.
- Adversarial: a tricky input that tends to make the model break. Use sparingly and intentionally.
- Impossible or out-of-scope: shows the model to refuse, respond with 'I do not know', or ask for more info.
Prompt patterns: zero-, one-, few-shot with counterexamples
Below are compact templates that build on grounding and exemplar selection. Use delimiters around rules and examples.
Zero-shot (grounded rule plus counterexample):
System: You are a strict summarizer. Only summarize content present in the source. If information is not in source, say: I cannot answer from the provided source.
Source:
---
[insert article here]
---
Instruction: Summarize the article in two sentences. Below is an example of an unacceptable summary:
Unacceptable example:
- "The article claims X about celebrity Y." <-- This is unacceptable because the article does not mention celebrities.
Now produce the summary.
One-shot (one positive and one counterexample):
Example 1 - Good:
Input: How does photosynthesis work?
Output: [short factual summary using only provided lesson text]
Example 2 - Bad:
Input: Can you speculate on an unknown protein?
Output: I cannot answer from the provided lesson.
Task: [new input]
Few-shot contrastive pattern (recommended): present paired examples that show both accept and reject cases, separated by clear labels and delimited context blocks.
---RULES---
- Use only facts present in the context block.
- If the fact is absent, refuse politely.
---EXAMPLES---
Good:
Input: ...
Output: ...
Bad:
Input: ...
Output: Refusal: not in source
---TASK---
[actual task]
Practical examples: boundary counterexamples in action
- Toxicity classification
- Positive exemplar: short toxic text labeled Toxic.
- Counterexample: similar wording that is borderline but non-toxic marked Non-toxic. This teaches the model the fine distinction.
- Style transfer (casual -> formal)
- Positive exemplar: casual sentence -> formal rewrite.
- Counterexample: a casual sentence that must not be changed (e.g., a brand name or code snippet) labeled Do not modify.
- Hallucination prevention
- Ground the model with a source and include a counterexample showing a made-up fact flagged as "Not supported by source" so the model learns to refuse.
Quick table: when to use which counterexample pattern
| Pattern | When to use | Pros | Cons |
|---|---|---|---|
| Zero-shot + 1 negative rule | When you have a clear rule and a grounded source | Fast; minimal examples | Less helpful for subtle distinctions |
| One-shot contrastive | When a single boundary example is critical | Clear signal, low cost | Might not generalize across diverse edges |
| Few-shot positive/negative pairs | When boundary space is wide | Stronger generalization, shows variety | Costly; risk of label leakage if done poorly |
Best practices for effective counterexamples
- Make them near misses: not wildly different from positives. The model learns from close contrasts.
- Label clearly: use explicit tags like Good, Bad, Accept, Reject, Refuse.
- Keep format consistent: structure, delimiters, and pinned sources reduce confusion.
- Balance quantity: 1 to 3 counterexamples per major boundary is often enough. Too many negatives can muddy the signal.
- Avoid contradictory negatives: if two negatives contradict, the model will be indecisive.
- Pair with grounding: when refusing or flagging, reference the grounded source to avoid hallucination.
- Use contrastive tokens: words like "Because" and short rationale lines in the exemplar help the model learn the why behind rejection.
Common pitfalls and how to dodge them
- Pitfall: counterexample creates a spurious rule (eg, model learns to reject any sentence containing a certain word). Fix: diversify negatives so the model learns the true boundary, not a correlated artifact.
- Pitfall: label leakage in few-shot examples where the label is too obviously tied to surface tokens. Fix: vary phrasing across examples.
- Pitfall: adversarial overuse produces brittle behavior. Fix: include a mix of safe and challenging cases, and validate on a held-out set.
Quick checklist before you hit go
- Did I include at least one near-miss negative for each nontrivial rule?
- Are negatives clearly labeled and formatted like positives?
- Is the boundary grounded with a source or explicit rule block?
- Did I avoid repeating surface tokens that create spurious patterns?
Final mic drop
Counterexamples are not mean. They are necessary. They tell the model: here is the house, and here is the cliff. Provide the model with a few well-chosen, tightly labeled negatives, and you will get fewer surprises and fewer creative inventions. The best prompts teach what to do and what not to do with equal clarity.
Key takeaways
- Use counterexamples to define boundaries, not to punish the model.
- Prefer near-miss negatives that clarify subtle distinctions.
- Pair counterexamples with grounding and clear labels to prevent hallucination and spurious rules.
Be dramatic in your boundaries. Models love to improvise. Let them improvise only within the space you actually want them to inhabit.
Comments (0)
Please sign in to leave a comment.
No comments yet. Be the first to comment!