Inferensys

Prompt

Counterexample Injection Prompt for Ambiguous Inputs

A practical prompt playbook for using Counterexample Injection Prompt for Ambiguous Inputs in production AI workflows.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, reader, and constraints for the Counterexample Injection Prompt for Ambiguous Inputs.

This prompt is for classification and extraction system builders who are hardening their models against borderline, ambiguous, or adversarial inputs. The core job is to teach the model to recognize uncertainty and respond with calibrated caution—such as requesting clarification, outputting a low-confidence label, or abstaining—instead of guessing. The ideal user is an AI engineer or prompt architect who already has a working prompt for a structured task (e.g., entity extraction, intent classification, or policy routing) but is seeing confident, wrong answers on edge cases in production. You need a set of real or synthetic ambiguous inputs and a clear definition of the desired cautious behavior before using this playbook.

Do not use this prompt when your primary problem is missing schema fields, incorrect output formats, or basic instruction-following failures. Those issues belong to schema control and output repair workflows. This prompt is also not a substitute for a safety policy or refusal prompt—it teaches ambiguity handling, not harm refusal. If your system operates in a regulated domain (healthcare, legal, finance), you must pair this prompt with human review checkpoints and evidence-grounding requirements. The counterexamples you inject will define the boundary between acceptable uncertainty and unacceptable guesswork, so invest time in selecting examples that mirror your real production failure modes.

Before implementing, audit your recent production traces to identify the specific ambiguous input patterns that cause confident misclassifications. Gather 5–10 representative borderline cases. For each, define the correct cautious output: should the model ask a clarifying question, return a confidence score below a threshold, or output a special AMBIGUOUS label? These decisions become your counterexample set. After injecting this prompt section, run your full eval suite—including both clear-cut cases and the ambiguous cases you targeted—to verify that the model didn't become overly hesitant on straightforward inputs. The next section provides the copy-ready template you'll adapt with your specific counterexamples and output schema.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Counterexample Injection Prompt delivers value and where it introduces risk. Use these cards to decide if this pattern fits your classification or extraction pipeline.

01

Good Fit: High-Stakes Classification with Ambiguous Boundaries

Use when: your classifier faces borderline cases where the model defaults to guessing. Counterexamples teach the model to recognize ambiguity and either request clarification or output a calibrated confidence score. Guardrail: pair counterexamples with an explicit abstention class or a confidence threshold below which the system escalates to human review.

02

Good Fit: Extraction Tasks with Common Misinterpretations

Use when: your extraction pipeline repeatedly misreads similar surface forms as the same entity type. Counterexamples showing near-miss inputs with corrected outputs reduce pattern overgeneralization. Guardrail: maintain a living counterexample set updated from production error logs and review it each sprint for staleness.

03

Bad Fit: Well-Separated, High-Confidence Inputs

Avoid when: your input classes are clearly separable and the model already achieves acceptable precision and recall. Adding counterexamples for obvious cases wastes context budget and can introduce confusion where none existed. Guardrail: run an A/B test comparing the counterexample-augmented prompt against the baseline on a held-out eval set before committing.

04

Bad Fit: Tasks Requiring Creative or Open-Ended Output

Avoid when: the goal is generation diversity rather than boundary precision. Counterexamples narrow the model's output distribution, which harms tasks like brainstorming, copywriting, or exploratory synthesis. Guardrail: restrict counterexample injection to classification, extraction, and structured decision tasks with clear right and wrong answers.

05

Required Inputs: Labeled Ambiguity Examples with Ground Truth

Risk: poorly chosen counterexamples that misrepresent the true decision boundary will train the model to make systematic errors. Guardrail: every counterexample must include the ambiguous input, the correct output, and a brief rationale explaining why the surface pattern is misleading. Source counterexamples from production error logs or expert annotation, not synthetic generation alone.

06

Operational Risk: Counterexample Drift Over Time

Risk: as your data distribution shifts, yesterday's counterexamples may become irrelevant or actively harmful by teaching the model to reject inputs that are now valid. Guardrail: schedule a monthly counterexample audit that compares each example against recent production data. Flag and remove counterexamples whose underlying pattern no longer appears or whose resolution has changed.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template that injects counterexamples to teach the model how to handle ambiguous inputs without guessing.

The following prompt template is designed to be copied directly into your prompt assembly pipeline. It forces the model to recognize ambiguity by presenting carefully chosen counterexamples—inputs that look similar to valid cases but should produce a different output, such as null, "unknown", or a structured uncertainty marker. The square-bracket placeholders must be replaced at runtime with your specific task configuration.

text
You are a precise classification system. Your task is to analyze the input and produce a structured output according to the schema defined below.

## Task Description
[TASK_DESCRIPTION]

## Output Schema
You must respond with a valid JSON object matching this schema:
[OUTPUT_SCHEMA]

## Critical Rule: Handling Ambiguity
If the input is ambiguous, contradictory, or missing information required to make a confident determination, you must not guess. Instead, set the primary field to `null` and populate the `uncertainty_reason` field with a brief explanation of what is unclear. Do not default to the most common class.

## Counterexamples (What NOT to Do)
The following examples demonstrate ambiguous inputs and the correct way to handle them. Study these carefully before processing the user's input.

### Counterexample 1
**Input:** [COUNTEREXAMPLE_INPUT_1]
**Incorrect Output (DO NOT DO THIS):** [INCORRECT_OUTPUT_1]
**Correct Output:** [CORRECT_OUTPUT_1]
**Why:** [RATIONALE_1]

### Counterexample 2
**Input:** [COUNTEREXAMPLE_INPUT_2]
**Incorrect Output (DO NOT DO THIS):** [INCORRECT_OUTPUT_2]
**Correct Output:** [CORRECT_OUTPUT_2]
**Why:** [RATIONALE_2]

### Counterexample 3
**Input:** [COUNTEREXAMPLE_INPUT_3]
**Incorrect Output (DO NOT DO THIS):** [INCORRECT_OUTPUT_3]
**Correct Output:** [CORRECT_OUTPUT_3]
**Why:** [RATIONALE_3]

## Positive Examples (What TO Do)
The following examples demonstrate clear inputs and their correct outputs.

### Example 1
**Input:** [POSITIVE_EXAMPLE_INPUT_1]
**Correct Output:** [POSITIVE_EXAMPLE_OUTPUT_1]

### Example 2
**Input:** [POSITIVE_EXAMPLE_INPUT_2]
**Correct Output:** [POSITIVE_EXAMPLE_OUTPUT_2]

## User Input
[USER_INPUT]

## Your Response (JSON only, no markdown fences)

To adapt this template for your own use case, replace the [TASK_DESCRIPTION] and [OUTPUT_SCHEMA] placeholders with your specific classification or extraction instructions and the exact JSON schema you expect. The counterexample blocks are the core teaching mechanism: each one must pair an ambiguous input with both an incorrect guess and the correct abstention or uncertainty output. Select counterexamples that are maximally confusing—inputs that sit right on your decision boundary. If your task has multiple ambiguity modes (e.g., missing entities, conflicting signals, out-of-distribution inputs), include at least one counterexample per mode. The positive examples should reinforce the desired behavior for clear-cut cases. Before deploying, run this prompt against a golden eval set that includes known ambiguous inputs and verify that the model's uncertainty_reason field is populated correctly and that primary fields are null when expected.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Counterexample Injection Prompt. Each placeholder must be populated before assembly. Validation notes describe how to check that the input is well-formed and safe to include.

PlaceholderPurposeExampleValidation Notes

[AMBIGUOUS_INPUT]

The borderline or ambiguous user input that the model must learn to handle without guessing

The client wants a 'fast' resolution. Is this about speed or a quick settlement?

Must contain genuine ambiguity. Validate by confirming at least two reasonable interpretations exist. Null not allowed.

[TASK_DESCRIPTION]

A clear statement of what the model should do when it encounters ambiguity

Classify the primary intent of the customer request. If multiple intents are equally plausible, output 'AMBIGUOUS' with a confidence breakdown.

Must include explicit instruction for the ambiguity case. Validate that the instruction does not contradict the counterexample behavior.

[WRONG_OUTPUT_EXAMPLE]

A concrete example of an incorrect or overconfident model response to the ambiguous input

Intent: speed_complaint (Confidence: 0.92)

Must represent a plausible but incorrect guess. Validate that the wrong output is factually unsupported by the ambiguous input alone. Null not allowed.

[CORRECT_OUTPUT_EXAMPLE]

A concrete example of the desired model response that acknowledges ambiguity

Intent: AMBIGUOUS. Possible intents: [speed_complaint, settlement_inquiry]. Confidence: 0.45 each. Requesting clarification.

Must demonstrate uncertainty calibration. Validate that the output includes explicit ambiguity markers, confidence scores, or clarification requests as specified in the task description.

[DISAMBIGUATION_RATIONALE]

A brief explanation of why the input is ambiguous and why guessing is harmful in this context

The word 'fast' could refer to processing speed or an expedited settlement. Misclassifying this as a speed complaint would route the ticket to the engineering queue instead of the legal team.

Must connect the ambiguity to a concrete downstream harm. Validate that the rationale is specific to the example, not generic. Null not allowed.

[CONFIDENCE_THRESHOLD]

The minimum confidence score required before the model is allowed to commit to a single classification

0.75

Must be a float between 0.0 and 1.0. Validate that the threshold is consistent with the task risk tolerance. If null, default to 0.8.

[OUTPUT_SCHEMA]

The expected structure for the model response, including fields for ambiguity signaling

{"intent": "string", "confidence": "float", "is_ambiguous": "boolean", "possible_intents": ["string"], "clarification_question": "string | null"}

Must be a valid JSON Schema or type definition. Validate that the schema includes fields for ambiguity signaling. Parse check required before prompt assembly.

[CLARIFICATION_POLICY]

Instruction for when and how the model should request clarification from the user

If is_ambiguous is true, generate one concise clarification question that disambiguates the top two candidate intents. Do not ask more than one question.

Must define a clear trigger condition and output constraint. Validate that the policy does not conflict with the output schema. Null allowed if clarification is handled downstream.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the counterexample injection prompt into a production classification or extraction pipeline with validation, retries, and confidence checks.

The counterexample injection prompt is not a standalone artifact; it is a pre-processing step that runs before the main classification or extraction prompt. In a production harness, you should assemble the counterexample block dynamically based on the input's ambiguity score. When an upstream ambiguity detector or low-confidence classifier flags an input, the harness retrieves relevant counterexamples from a curated library, injects them into the prompt template, and re-runs inference. This two-pass architecture keeps the common case fast while adding targeted instruction for borderline inputs.

Wire the prompt into your application as a conditional branch. First, run the primary classifier with a confidence threshold. If confidence falls below the threshold (e.g., <0.85 for a softmax classifier or the model outputs an explicit low-confidence token), trigger the counterexample injection path. In this path, query your example library using the input text and the top-k predicted classes. Insert the retrieved counterexamples into the [COUNTEREXAMPLES] placeholder of the prompt template. Use a structured format for each counterexample: Input: [ambiguous text] → Incorrect: [wrong output] → Correct: [right output] → Why: [boundary explanation]. After injection, re-run inference and compare the new output against the original. Log both passes, the injected examples, and the confidence delta for observability.

Validation must check three things. First, verify that the model did not simply flip to another high-confidence wrong answer—compare the new output against a known ground-truth set if available. Second, confirm that the output includes an explicit ambiguity handling signal (e.g., a needs_review flag, a confidence score, or a structured abstention marker) rather than a guess dressed in confident language. Third, enforce a retry budget: if the model still produces low-confidence or inconsistent outputs after two counterexample injection attempts, escalate to a human review queue. For high-risk domains like healthcare or legal classification, always require human sign-off on any output that passed through the counterexample injection path, regardless of the final confidence score.

Model choice matters. Counterexample injection works best with instruction-following models that attend carefully to in-context examples (e.g., GPT-4, Claude 3.5, Gemini 1.5 Pro). Smaller or older models may ignore counterexamples or treat them as positive examples, worsening the ambiguity problem. Test your chosen model's counterexample sensitivity by running a calibration set: inject counterexamples for known ambiguous cases and measure whether the model shifts its output in the correct direction. If the model consistently ignores counterexamples, consider fine-tuning on a dataset that includes explicit boundary demonstrations instead of relying on in-context injection.

Log every counterexample injection event with the input text, ambiguity trigger reason, retrieved examples, pre-injection output, post-injection output, confidence scores, and final disposition (accepted, escalated, or auto-resolved). This log becomes your evaluation dataset for tuning the ambiguity threshold, curating the example library, and detecting when counterexamples become stale or counterproductive. Run a weekly audit query: find cases where counterexample injection made the output worse, and remove or rewrite those examples.

IMPLEMENTATION TABLE

Expected Output Contract

Define the exact shape of the counterexample injection block so it can be validated before insertion into the main prompt.

Field or ElementType or FormatRequiredValidation Rule

counterexample_block

string

Must parse as a single text block with clear delimiters from surrounding instructions

counterexample_entry

array of objects

Array length must be >= 2; each entry must contain input, incorrect_output, correct_output, and explanation fields

counterexample_entry.input

string

Must be non-empty; must represent an ambiguous or borderline case matching the target domain

counterexample_entry.incorrect_output

string or object

Must be a plausible but wrong model response; type must match the expected output schema of the main task

counterexample_entry.correct_output

string or object

Must be the desired model response; type must match the expected output schema of the main task

counterexample_entry.explanation

string

Must be non-empty; must explain why the incorrect output is wrong and how ambiguity should be resolved

ambiguity_instruction

string

Must contain explicit guidance to abstain or flag uncertainty when input matches counterexample patterns

confidence_field

string or null

If present, must be a valid JSON path to a confidence score field in the output schema; null allowed

PRACTICAL GUARDRAILS

Common Failure Modes

Counterexample injection fails silently when ambiguity is misclassified as certainty. These failure modes break confidence calibration and cause the model to guess instead of flagging uncertainty.

01

Counterexamples Treated as Positive Examples

What to watch: The model learns the surface pattern of the counterexample but misses the 'this is ambiguous, do not guess' signal. It starts confidently classifying borderline inputs into the nearest category instead of abstaining. Guardrail: Place counterexamples in a dedicated <counterexamples> block with explicit instructions to treat them as non-examples. Use eval pairs where the correct output is a refusal or uncertainty marker, not a class label.

02

Ambiguity Threshold Collapse Under Input Noise

What to watch: Minor input variations (typos, synonym swaps, reordering) cause the model to flip from 'uncertain' to a confident wrong answer. The counterexample boundary is too brittle. Guardrail: Include counterexamples with the same noise patterns you expect in production (misspellings, truncated text, mixed languages). Test with a perturbation eval set that introduces controlled noise and measures flip rate.

03

Over-Abstention from Overly Broad Counterexamples

What to watch: Counterexamples that are too broad teach the model to abstain on valid inputs that share surface features with the counterexample. The model becomes uselessly cautious. Guardrail: Scope each counterexample to a specific ambiguity type (e.g., 'missing required field' vs. 'conflicting evidence'). Track abstention rate by input category and set a maximum acceptable abstention threshold before the prompt is considered broken.

04

Confidence Score Miscalibration After Injection

What to watch: The model outputs high confidence on ambiguous inputs because the counterexamples taught it to recognize ambiguity but not to express it in the confidence field. The numeric score and the textual hedging diverge. Guardrail: Include counterexamples that demonstrate the correct confidence format (e.g., confidence: 0.2 with needs_review: true). Validate that confidence scores correlate with ambiguity labels in your eval set using a calibration metric like ECE.

05

Counterexample Leakage into Downstream Reasoning

What to watch: In multi-step or chain-of-thought prompts, the model references counterexample content in its reasoning for unrelated inputs. The counterexample contaminates the reasoning trace. Guardrail: Isolate counterexamples in a separate prompt section with clear scope boundaries. Add an instruction: 'Do not reference counterexamples in your reasoning for other inputs.' Test with inputs that are semantically distant from counterexamples and scan reasoning traces for leakage.

06

Silent Drift When Input Distribution Shifts

What to watch: Counterexamples selected during development stop matching production ambiguity patterns after a data shift. The model stops flagging uncertainty on new types of borderline inputs. Guardrail: Log inputs where the model was confident but a human reviewer flagged ambiguity. Periodically run a drift detection eval that compares counterexample coverage against recent ambiguous production inputs and flags coverage gaps.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for testing whether the counterexample injection prompt produces calibrated, ambiguity-aware outputs before shipping to production.

CriterionPass StandardFailure SignalTest Method

Ambiguity Recognition

Model outputs explicit ambiguity flag or abstention label when [INPUT] contains genuine borderline features

Model assigns a confident class label to an input that human reviewers split 60/40 or closer

Run 20 borderline inputs from a held-out ambiguity test set; measure abstention rate against human agreement baseline

Confidence Calibration

Model-assigned confidence score correlates with human labeler agreement (Spearman ρ ≥ 0.7)

High-confidence outputs (>0.9) on inputs where human agreement is below 0.7; low-confidence outputs (<0.5) on clear-cut inputs

Compute rank correlation between model confidence and inter-annotator agreement across 50+ labeled examples

Counterexample Discrimination

Model correctly distinguishes [POSITIVE_EXAMPLE] from [NEGATIVE_EXAMPLE] patterns on held-out test pairs

Model applies negative-example refusal pattern to inputs that match positive-example structure; or accepts inputs matching negative-example structure

Construct 10 minimal pair tests where only the ambiguity-relevant feature differs; measure discrimination accuracy

Over-Refusal Rate

Refusal or abstention rate on clearly valid inputs is below 5%

Model abstains on unambiguous inputs that match [POSITIVE_EXAMPLE] patterns with high inter-annotator agreement

Run 30 unambiguous valid inputs through the prompt; count false abstentions

Under-Refusal Rate

Refusal or abstention rate on clearly invalid or unsafe inputs is above 95%

Model produces a confident valid output for inputs matching [NEGATIVE_EXAMPLE] patterns

Run 20 unambiguous invalid inputs through the prompt; count false acceptances

Boundary Stability

Output label does not flip when non-ambiguous features of [INPUT] are perturbed (paraphrase, synonym swap)

Model changes classification or confidence by more than 0.3 when surface form changes but semantics are preserved

Generate 5 paraphrases for each of 10 borderline inputs; measure output variance across paraphrases

Schema Compliance

Output strictly matches [OUTPUT_SCHEMA] including ambiguity_flag field, confidence field, and reasoning field

Missing ambiguity_flag; confidence outside 0.0-1.0 range; reasoning field contains only the predicted class without ambiguity discussion

Validate output against JSON schema with required fields; check field types and value ranges programmatically

Reasoning Trace Quality

Reasoning field references specific features from [INPUT] that match or conflict with [POSITIVE_EXAMPLE] or [NEGATIVE_EXAMPLE] patterns

Reasoning field contains generic text ('this seems ambiguous') without citing input features or example patterns

Manual review of 20 reasoning traces; check for explicit reference to input features and example alignment

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base counterexample injection template. Use 2–3 hand-picked counterexamples that illustrate the most common ambiguity failure mode you see in manual testing. Insert them directly after the classification instructions, before any positive examples.

code
[AMBIGUITY_INSTRUCTION]

Counterexamples (do NOT classify these as [TARGET_CLASS]):
- Input: [AMBIGUOUS_INPUT_1] → Expected: [CORRECT_BOUNDARY_CLASS] because [RATIONALE]
- Input: [AMBIGUOUS_INPUT_2] → Expected: [CORRECT_BOUNDARY_CLASS] because [RATIONALE]

[POSITIVE_EXAMPLES]

Watch for

  • Counterexamples that are too obvious and don't teach boundary recognition
  • Overfitting to the specific counterexamples without generalizing to new ambiguous inputs
  • Missing confidence calibration—model still guesses on borderline cases instead of flagging uncertainty
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.