Generative AI & Agentic AILLM fundamentals and prompt design

Few-shot examples: choose cases that expose the boundary

PK
Pankit Kumar
Sr. Data Scientist at Parexel (a Goldman Sachs–backed company) · 20 September 2026 · 2 min read
Technically reviewed by Ishaan Sharma
In this article (5 sections)

Examples teach more than output style. They imply which inputs are supported, when the system should abstain and how conflicts are resolved. Choosing only easy cases can make the prompt look successful while leaving its critical boundary unspecified.

Cover behaviours deliberately

The offline foundations lab defines four examples.

python
from foundation_cases import few_shot_case

result = few_shot_case()
assert result["coverage"] == 4
assert result["selected_by_similarity_only"] is False
assert set(result["covered_boundaries"]) == {
    "supported", "unsupported", "contradictory", "untrusted_instruction"
}

The set includes a normal supported case, missing evidence, contradictory evidence and an untrusted instruction in retrieved content. No model executes; the check verifies the example-selection policy.

Build an example inventory

For each candidate, record the task slice, intended behaviour, why it is difficult and which instruction it clarifies. Prefer a minimal set that covers distinct boundaries. Near-duplicate normal examples can consume context without teaching new behaviour.

Match the real input distribution, but preserve rare high-impact cases. An approval assistant might see missing documents infrequently, yet that case deserves explicit abstention behaviour. Include the exact structured output and evidence references expected from the application.

Keep examples separate from evaluation

Few-shot examples are part of the prompt and therefore training-like context. Do not count them as evaluation cases. Freeze a separate labelled set before comparing prompt versions. Check whether changing one example helps its slice while harming another.

Avoid copying sensitive customer content into prompts. Create representative redacted or synthetic examples with reviewed labels. Track provenance, rights and version. If examples are retrieved dynamically, test selection leakage and injection risks as part of the system.

The Generative & Agentic AI course connects few-shot design to context budgeting, prompt evaluation and adversarial testing.

Exercise

List ten candidate examples for a document decision. Tag their behavioural boundaries, select the smallest useful set and justify every inclusion. Evaluate against a separate fixed set, then remove each example in turn to measure its effect.

Continue learning

This article is part of the LLM fundamentals and prompt design sequence. Use the neighbouring tasks when you need the prerequisite or the next application.

Reference: OpenAI prompt-engineering guidance.

PK
Pankit Kumar
Lead Instructor, NeuraPath Academy

Pankit Kumar has 10 years in Data Science & AI, building and shipping production systems in regulated pharma and clinical environments. He is a freelance trainer at Boston Institute of Analytics, AnalytixLabs and Scaler, and has taught this material to thousands of working professionals.

This article is part of our Generative & Agentic AI programme — 3 months. Add practical GenAI, retrieval and agent-building skills to your existing toolkit.

Explore Generative & Agentic AI
Counselling is free · no obligation

Not sure which programme fits?

Tell us your background and we will map it to the right entry point — including saying so when a cheaper programme is the better fit. A counsellor replies within one working day.