Inferensys

Prompt

Example Augmentation with Hallucination Injection for Detection Training Prompt

A practical prompt playbook for generating labeled training data for hallucination detection systems by injecting controlled factual errors, unsupported claims, and fabricated citations into seed examples.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, ideal user, required context, and when this prompt is the wrong tool.

This prompt is designed for machine learning engineers and AI safety teams who are building or fine-tuning hallucination detection models. Its primary job is to transform a set of factually correct seed examples into a labeled training dataset where each example contains a controlled, documented factual error. You need this when you have a high-quality corpus of ground-truth outputs but lack sufficient negative examples to teach a classifier or judge model to reliably identify fabrications, unsupported claims, and citation errors.

The ideal user has a collection of verified, source-grounded text passages—such as RAG outputs with citations, summarized research findings, or extracted clinical notes—and needs to systematically degrade them. The prompt requires you to specify the type of hallucination to inject (e.g., entity swap, fabricated citation, contradictory claim), a difficulty level for the detection task, and the expected output schema for the augmented example. You should not use this prompt if your seed data already contains unverified claims, as the injection process will compound existing errors and produce a noisy, unreliable training set. It is also unsuitable for generating adversarial content intended to evade production safety filters without a formal red-teaming process and human review.

Before integrating this prompt into a data generation pipeline, ensure you have a validation step that confirms the injected error matches the requested type and difficulty. A common failure mode is generating an error that is either trivially obvious or semantically nonsensical, which teaches the detector to latch onto superficial patterns rather than genuine factual inconsistency. Start by running this prompt on a small, manually reviewed batch of 20–50 seeds to calibrate the [ERROR_TYPE] and [DIFFICULTY] parameters before scaling to thousands of examples. Pair this with the 'Example Validation and Quality Assurance' playbook to automatically filter out low-quality augmentations.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Hallucination injection is a precision tool for building detectors, not a general-purpose augmentation technique.

01

Good Fit: Hallucination Detector Training

Use when: you are building a classifier, judge model, or evaluation pipeline that must distinguish factual claims from fabricated ones. Guardrail: label each injected error with type, severity, and source so your detector learns granular distinctions, not just binary fact-or-fiction.

02

Bad Fit: General Content Generation

Avoid when: the output will be shown to end users, stored as ground truth, or used to train generative models without clear contamination boundaries. Guardrail: quarantine hallucination-injected datasets and never mix them with production training data unless explicitly building a detector.

03

Required Inputs

You must provide: verified seed examples with known factual ground truth, an error taxonomy, and a difficulty calibration target. Guardrail: if you cannot confirm the seed example is factually correct, do not inject hallucinations—you will create unlabeled noise that poisons downstream evaluation.

04

Operational Risk: Contamination Spread

What to watch: hallucination-injected examples leaking into fine-tuning datasets, eval benchmarks, or RAG retrieval corpora. Guardrail: use strict data lineage tracking, separate storage buckets, and naming conventions that make injected datasets immediately identifiable in any pipeline.

05

Operational Risk: Unrealistic Error Patterns

What to watch: the prompt produces hallucinations that are too obvious, too subtle, or stylistically different from real model errors. Guardrail: periodically compare injected errors against production hallucination logs and recalibrate difficulty parameters so your detector trains on representative failures.

06

When to Escalate Beyond a Prompt

Avoid relying solely on this prompt when: you need millions of examples, real-time injection, or error patterns that require domain-expert review. Guardrail: for production-scale detector training, wrap this prompt in a pipeline with human audit sampling, automated factuality verification of seeds, and schema validation on every output.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt for generating training data with controlled factual errors to build hallucination detection systems.

This prompt template is designed to take a factually correct seed example and inject controlled hallucinations—unsupported claims, fabricated citations, entity swaps, and subtle factual distortions—to create labeled training data for hallucination detection models. The template uses square-bracket placeholders for all variable inputs, making it straightforward to integrate into a data generation pipeline. Each generated example includes an error-type label and a difficulty calibration score, which are essential for training classifiers that can distinguish between different categories of hallucination and for building progressive evaluation sets.

text
You are a training data generator for a hallucination detection system. Your task is to take a factually correct seed example and produce a set of augmented examples, each containing a controlled factual error. You must vary the error type, subtlety, and position within the text.

## INPUT
Seed Example: [SEED_TEXT]
Domain Context: [DOMAIN_DESCRIPTION]
Source Grounding: [SOURCE_EVIDENCE]

## OUTPUT SCHEMA
Return a JSON array of augmented examples. Each object must have these fields:
{
  "augmented_text": "string (the modified text with injected hallucination)",
  "error_type": "enum: unsupported_claim | fabricated_citation | entity_swap | numerical_distortion | temporal_error | attribution_error | contradictory_statement | overgeneralization",
  "error_span": "string (exact substring that contains the error)",
  "error_description": "string (explanation of what was changed and why it's wrong)",
  "difficulty_level": "enum: easy | moderate | hard | adversarial",
  "ground_truth_correction": "string (the correct version of the error span)",
  "seed_preservation_score": "float 0.0-1.0 (how much of the original structure and non-error content is preserved)"
}

## CONSTRAINTS
- Generate exactly [NUM_VARIANTS] augmented examples.
- Distribute error types across: [ERROR_TYPE_DISTRIBUTION].
- Distribute difficulty levels across: [DIFFICULTY_DISTRIBUTION].
- For "easy" difficulty: make the error obvious and easily detectable by a fact-checker.
- For "moderate" difficulty: make the error plausible but verifiable against the source evidence.
- For "hard" difficulty: make the error subtle, requiring domain expertise or cross-referencing to detect.
- For "adversarial" difficulty: make the error nearly indistinguishable from a correct statement, such as a slightly wrong date, a subtly altered statistic, or a citation that looks real but doesn't exist.
- Never alter more than [MAX_ERROR_PERCENTAGE]% of the original text.
- Preserve the original text structure, tone, and formatting outside the error span.
- For "fabricated_citation" errors, generate realistic-looking but non-existent citations (authors, titles, journals, DOIs).
- For "entity_swap" errors, replace a named entity with a similar but incorrect one from the same domain.
- Do not introduce errors that are offensive, harmful, or that could propagate misinformation if accidentally released. All errors must be clearly labeled and controllable.
- If the seed example contains [SENSITIVE_ATTRIBUTES], do not alter those spans.

## EXAMPLES
[FEW_SHOT_EXAMPLES]

## OUTPUT FORMAT
Return only the JSON array. No additional text, no markdown fences.

To adapt this template for your pipeline, start by defining your seed examples and source evidence carefully—the quality of the hallucinations depends on having a clear ground truth to deviate from. The [ERROR_TYPE_DISTRIBUTION] and [DIFFICULTY_DISTRIBUTION] placeholders let you control the composition of your training set; for an initial detection model, aim for a balanced mix of error types with a heavier weight on moderate and hard examples. The [FEW_SHOT_EXAMPLES] placeholder is critical: include at least three worked examples showing different error types and difficulty levels to calibrate the model's output quality. After generation, validate each augmented example by checking that the error_span is an exact substring match in the augmented_text, that the ground_truth_correction matches the original seed, and that the seed_preservation_score is above 0.85. For high-stakes detection systems, route a sample of generated examples through human review before adding them to your training set, and log all generation parameters for auditability.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the hallucination injection prompt. Each variable controls how errors are introduced, labeled, and calibrated for detection training data.

PlaceholderPurposeExampleValidation Notes

[SEED_EXAMPLE]

The original ground-truth example to corrupt with controlled hallucinations

{"input": "What is the capital of France?", "output": "Paris is the capital of France."}

Must be a valid JSON object with input and output fields. Reject if output contains fewer than 3 factual claims.

[ERROR_TYPES]

Comma-separated list of hallucination categories to inject into the seed

fabricated_citation, unsupported_claim, entity_swap, false_precision

Each value must match a known error taxonomy entry. Reject unknown types. At least one type required.

[ERROR_COUNT]

Number of distinct errors to inject into the output

3

Must be an integer between 1 and the number of verifiable claims in the seed output. Reject if count exceeds claim count.

[DIFFICULTY_LEVEL]

Controls how subtle or obvious the injected errors are

medium

Must be one of: easy, medium, hard, adversarial. Easy errors are blatant contradictions. Hard errors require domain knowledge to detect.

[OUTPUT_SCHEMA]

Target JSON schema for the augmented output including error annotations

{"augmented_output": "string", "injected_errors": [{"span": "string", "type": "string", "difficulty": "string"}]}

Schema must include augmented_output and injected_errors fields. injected_errors must be an array with span, type, and difficulty per entry.

[CITATION_STYLE]

Format for fabricated citations when error_types includes fabricated_citation

Author (Year). Title. Journal, Volume(issue), pages.

Required only when fabricated_citation is in error_types. Must specify a complete citation template. Reject empty or placeholder-only values.

[DOMAIN_CONTEXT]

Optional domain knowledge constraints to make hallucinations plausible within a field

medical: cardiology, evidence_level: RCT, date_range: 2019-2024

If provided, injected errors must stay within domain boundaries. Null allowed. Validate domain terms against known taxonomy if non-null.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire hallucination-injected example generation into a training data pipeline with validation, calibration, and quality gates.

This prompt is designed to run as a batch job, not a real-time user-facing endpoint. The typical integration pattern is a Python script or Airflow DAG that reads a seed dataset of verified factual examples, iterates through each record, calls the LLM with this prompt, validates the structured output, and writes the augmented examples to a training data store. Because the prompt deliberately generates false claims, the output must never flow directly into a production RAG system or customer-facing model without explicit labeling and downstream filtering. The primary consumers are ML engineers building hallucination detection classifiers and factuality evaluators who need controlled negative examples.

Pipeline integration steps: (1) Load seed examples from a trusted source with ground-truth labels. (2) For each seed, construct the prompt with [SEED_EXAMPLE], [ERROR_TYPES], [DIFFICULTY_LEVEL], and [OUTPUT_SCHEMA] populated. (3) Call the model with response_format set to JSON mode if available, or enforce schema via the prompt's output contract. (4) Validate each returned example: confirm the error_type field matches one of the requested types, verify the injected_claim is actually present in the augmented_text, and check that the detection_difficulty field is populated. (5) Run a secondary verification prompt or heuristic to confirm the injected error is genuinely false—this prevents the model from accidentally generating a correct statement and labeling it as a hallucination. (6) Append validated records to the training set with metadata including seed ID, error type, difficulty, and generation timestamp.

Model choice and retries: Use a model with strong instruction-following and structured output capabilities. For high-volume pipelines, consider a faster model for initial generation and a more capable model for spot-check validation. Implement exponential backoff with a maximum of three retries on schema validation failures. If a seed example fails validation after three attempts, log the failure with the seed ID and error details, then skip to the next record. Do not silently drop failures—these often indicate seeds that are too short, too ambiguous, or contain edge cases worth reviewing. Human review gate: For the first batch of 50-100 generated examples, have a domain expert manually review a random sample to confirm that injected errors are plausible but false, that difficulty labels are calibrated, and that no sensitive information from seeds is leaking in unexpected ways. After the initial gate, switch to periodic spot-check sampling rather than full review.

What to avoid: Do not use this prompt on seeds that contain real user data, PII, or confidential information without redaction. Do not store generated examples in the same dataset as verified factual examples without clear labeling—a source: 'hallucination_injected' metadata field is the minimum. Do not assume the model will always inject exactly one error per example; validate the count and discard or repair outputs that inject zero or multiple unlabeled errors. Finally, track the distribution of error types and difficulty levels across your generated set to ensure balanced coverage for downstream classifier training.

PRACTICAL GUARDRAILS

Common Failure Modes

When injecting synthetic hallucinations into training data, these are the most common failure modes that degrade detection model performance. Each card identifies a specific risk and provides a concrete guardrail to implement before scaling your augmentation pipeline.

01

Hallucination Leakage into Clean Examples

What to watch: Augmented examples with injected hallucinations accidentally contaminate the clean example set used for training or evaluation. This creates a false baseline where the detection model learns to expect hallucinations everywhere or, worse, learns to ignore real hallucinations because they blend with synthetic ones. Guardrail: Maintain strict physical separation between augmented and clean datasets. Use checksum verification on clean examples before each training run. Implement a source_label field on every example that traces back to the augmentation run ID, and audit a random sample of clean examples weekly for contamination.

02

Detectable Hallucination Patterns

What to watch: The augmentation prompt introduces systematic patterns—consistent phrasing, predictable error types, or uniform insertion positions—that the detection model learns to recognize as synthetic rather than genuine hallucinations. The model becomes a pattern-matching classifier instead of a factuality verifier. Guardrail: Vary hallucination insertion strategies across multiple prompt templates. Randomize insertion position (beginning, middle, end), error type distribution, and linguistic framing. Run a classifier test where a separate model attempts to distinguish synthetic from real hallucinations; if accuracy exceeds 70%, your patterns are too detectable.

03

Difficulty Miscalibration

What to watch: Generated hallucinations are either trivially obvious (contradicting well-known facts) or impossibly subtle (requiring domain expertise beyond the detection model's capability). Both extremes produce training data that fails to teach useful discrimination boundaries. Guardrail: Assign a difficulty label to each augmented example using a calibrated rubric (e.g., Easy: contradicts common knowledge, Medium: requires source comparison, Hard: requires multi-step reasoning to detect). Validate difficulty distribution against a human-annotated sample. Ensure at least 30% of examples fall in the Medium band where learning transfer is highest.

04

Error-Type Collapse

What to watch: The augmentation prompt over-produces one error type—fabricated citations, for example—while neglecting unsupported claims, factual contradictions, or temporal errors. The detection model becomes specialized to a narrow hallucination category and fails on production diversity. Guardrail: Define an error taxonomy upfront (e.g., fabricated source, factual contradiction, unsupported extrapolation, entity hallucination, temporal error, quantitative error). Track per-category counts during augmentation. Set minimum thresholds for each category and re-prompt with explicit category targeting when distributions skew.

05

Context-Contradiction Blindness

What to watch: Injected hallucinations contradict general world knowledge but remain consistent with the provided context. The detection model learns to flag only external-knowledge violations while missing the most dangerous production failure: claims that sound plausible but contradict the user's own source material. Guardrail: Include a dedicated augmentation pass that injects claims contradicting the provided context while remaining factually true in isolation. Label these as context_contradiction and weight them at least 25% of the training set. Verify that the detection model's recall on context-contradiction examples matches its recall on external-knowledge hallucinations.

06

Annotation Drift in Error Labeling

What to watch: The augmentation prompt's self-labeling of injected errors becomes inconsistent over large batches—error spans shift, severity labels drift, or hallucination types are misclassified. Downstream training inherits these labeling errors, producing a detection model with noisy supervision. Guardrail: Implement a validation pass where a separate prompt or lightweight classifier reviews a random 10% sample of augmented examples and checks error-label alignment. Track inter-annotator agreement between the augmentation prompt and the validator. If agreement drops below 85%, pause augmentation and recalibrate the injection prompt with updated examples of correct labeling.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the quality of hallucination-injected examples before adding them to a detection training set. Each criterion targets a specific failure mode in synthetic data generation.

CriterionPass StandardFailure SignalTest Method

Hallucination Presence

At least one verifiable factual error, unsupported claim, or fabricated citation exists in the output

Output is factually identical to the seed example with no injected errors

Run a fact-checking prompt on the output against the seed source. Flag if zero errors detected.

Error Type Label Accuracy

The [ERROR_TYPE] label matches the actual hallucination category present in the output

Label says 'fabricated_citation' but output contains a numerical error with no citation

Parse the output for error indicators. Cross-reference each indicator against the [ERROR_TYPE] label. Fail if mismatch.

Seed Structure Preservation

Output maintains the original [OUTPUT_SCHEMA] fields, nesting, and data types of the seed example

Output drops required fields, changes field types, or adds unrequested structure

Validate output against [OUTPUT_SCHEMA] using a JSON Schema validator. Fail on any schema violation.

Detection Difficulty Calibration

The hallucination is subtle enough to require careful reading, not an obvious nonsense insertion

Output contains a glaring contradiction like 'the patient, a 45-year-old infant' or a URL to 'example.fake'

Human review by one annotator: can they spot the error in under 5 seconds? If yes, difficulty is too low.

Non-Hallucinated Content Fidelity

All non-injected portions of the output are factually consistent with the seed example

Unintended factual drift appears in sections that were not targeted for hallucination injection

Diff the output against the seed example. Flag any factual change outside the injected error span.

Citation Fabrication Realism

Fabricated citations follow the format, style, and domain conventions of real citations in the seed domain

Fabricated citation uses placeholder text like '[AUTHOR], [TITLE]' or an obviously fake DOI prefix

Regex check for unresolved placeholders. Spot-check fabricated citation format against a real citation style guide for the domain.

Controlled Injection Scope

Only the number of hallucinations specified by [INJECTION_COUNT] are present in the output

Output contains 4 injected errors when [INJECTION_COUNT] was set to 2

Count the number of hallucination spans in the output. Compare to [INJECTION_COUNT]. Fail if count mismatch.

Downstream Detection Utility

A baseline hallucination detection prompt correctly flags the injected error span with confidence above [CONFIDENCE_THRESHOLD]

Detection prompt misses the injected error or flags a correct statement as hallucinated

Run the output through your target detection prompt. Check that the flagged span matches the injected error location.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a small seed set of 5-10 examples. Inject only one error type per example initially. Skip the difficulty calibration field and use simple labels like hallucination_type: ["fabricated_citation"]. Run manual spot checks on 20 outputs before scaling.

Watch for

  • Over-injection: too many errors per example makes detection labels ambiguous
  • Error-type leakage: the model may copy error patterns into supposedly clean sections
  • Missing diversity: if all seeds are from one domain, hallucinations will be domain-narrow
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.