This prompt is a post-generation repair tool for RAG systems, documentation assistants, and any AI product where a model output contains citations that cannot be traced back to a provided evidence set. Its job is to identify invented references, remove or replace them with abstention markers, and produce a structured audit log so downstream systems and human reviewers know exactly what was fabricated. Use this prompt when citation integrity is a hard requirement and hallucinated references would erode user trust, break compliance, or corrupt downstream databases.
Prompt
Hallucinated Citation Removal Prompt Template

When to Use This Prompt
Determines the right operational context for deploying a hallucinated citation removal prompt in production AI systems.
This is not a prompt for generating citations. It assumes a model has already produced a response with inline citation markers and that you have a ground-truth set of valid source identifiers to check against. The prompt works best when you can provide both the original model output and the complete list of authorized source IDs as input. It is designed for batch repair workflows, real-time guardrails before user-facing display, and compliance audit pipelines where every citation must be traceable to an approved source. Do not use this prompt when you lack a definitive source list—without ground truth, the repair itself becomes unreliable.
Before deploying this prompt, ensure your pipeline captures the raw model output, the authorized source ID list, and any citation format conventions your system enforces. Wire the prompt into a post-processing step that runs after generation but before the response reaches the user or database. For high-risk domains, always route outputs with unresolved hallucinations to human review rather than silently removing citations. The audit log this prompt produces should be persisted alongside the repaired output for downstream traceability and debugging.
Use Case Fit
Where the Hallucinated Citation Removal Prompt Template works and where it does not.
Good Fit: RAG Systems with a Closed Evidence Set
Use when: you have a finite, known corpus of source documents and the model's answer must only cite from that set. Guardrail: Provide the full evidence set as structured context with unique IDs so the prompt can perform exact-match verification.
Bad Fit: Open-Domain Creative Writing
Avoid when: the task is creative generation, opinion, or brainstorming where citations are not required. Running a strict removal prompt here will strip stylistic references and degrade output quality. Guardrail: Gate the prompt behind a classifier that detects whether the input task requires grounded citations.
Required Inputs
Risk: The prompt cannot function without a structured evidence map. Guardrail: Always pass a JSON array of source objects with id, text, and metadata fields. The prompt uses this as the single source of truth for citation validation.
Operational Risk: False Positives on Paraphrased Sources
Risk: The model may flag a legitimate citation as hallucinated if the cited text is paraphrased rather than quoted verbatim. Guardrail: Include a semantic similarity threshold in the prompt instructions and output a match_type field (exact, paraphrase, no_match) to support downstream review.
Operational Risk: Silent Hallucination Pass-Through
Risk: The repair prompt itself can hallucinate a justification for keeping a bad citation. Guardrail: Always run the output through a secondary evaluation step that independently verifies each remaining citation against the source corpus using a deterministic string-match or embedding threshold.
Not a Substitute for Retrieval Quality
Risk: Teams may treat this prompt as a patch for poor retrieval. If the retriever consistently fails to surface relevant documents, the prompt will strip most citations, leaving an answer with no support. Guardrail: Monitor the hallucination audit log's removal rate. A rate above 30% signals a retrieval problem, not a citation problem.
Copy-Ready Prompt Template
A reusable prompt template for identifying and removing hallucinated citations that have no matching source in the provided evidence set.
This prompt template is designed to be dropped into a post-generation repair loop. It receives the original model output and the authoritative evidence set, then produces a cleaned version with hallucinated citations removed or replaced by abstention markers. The template uses square-bracket placeholders so you can wire it into your application's context assembly layer without manual editing.
textYou are a citation auditor. Your job is to identify and remove citations in the provided [OUTPUT_TEXT] that have no matching source in the [EVIDENCE_SET]. [EVIDENCE_SET] [SOURCE_METADATA] [OUTPUT_TEXT] [CONSTRAINTS] - Do not modify any text that is not a citation. - For each citation, check whether the cited source exists in [EVIDENCE_SET] by matching on [MATCH_FIELD]. - If a citation has no match, replace it with [ABSTENTION_MARKER]. - If a citation has a partial match, flag it as [PARTIAL_MATCH_ACTION]. - Preserve the original text structure, formatting, and non-citation content exactly. [OUTPUT_SCHEMA] { "cleaned_output": "string (the full output with hallucinated citations removed or replaced)", "audit_log": [ { "original_citation": "string", "match_status": "MATCH | NO_MATCH | PARTIAL_MATCH", "matched_source_id": "string | null", "action_taken": "RETAINED | REMOVED | REPLACED_WITH_ABSTENTION | FLAGGED", "confidence": "HIGH | MEDIUM | LOW" } ], "summary": { "total_citations_found": "integer", "hallucinated_citations_removed": "integer", "partial_matches_flagged": "integer", "retained_citations": "integer" } } [EXAMPLES] Example 1: Input: "The sky is blue (Smith, 2023)." Evidence set contains: Smith, 2023 Output: RETAINED, no change. Example 2: Input: "Water is wet (Johnson, 2019)." Evidence set does not contain: Johnson, 2019 Output: "Water is wet [citation not found]." Audit log entry: NO_MATCH, REMOVED. [RISK_LEVEL] HIGH - Incorrect citation removal can delete valid references. Always log every removal decision. Route outputs with more than [REMOVAL_THRESHOLD]% citations removed for human review before publishing.
To adapt this template, replace each square-bracket placeholder with your application's actual values. [EVIDENCE_SET] should contain the full text or structured records of all authorized sources. [MATCH_FIELD] defines which identifier to use for matching—typically a source ID, author-date pair, or URL. Set [ABSTENTION_MARKER] to your preferred placeholder text, such as [citation not found] or [source unavailable]. The [OUTPUT_SCHEMA] is designed for programmatic consumption: your repair harness should parse the JSON response, validate the audit log against the original output, and route high-removal cases to a human review queue. Always test with known hallucinated citations before deploying to production.
Prompt Variables
Required and optional inputs for the Hallucinated Citation Removal prompt. Each variable must be populated before the prompt is assembled and sent to the model. Missing or malformed inputs are the most common cause of false negatives in hallucination detection.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[RESPONSE_TEXT] | The full model-generated text containing inline citations that must be audited for hallucination. | According to Smith (2024), the API latency improved by 40% [ref:42]. | Must be a non-empty string. Strip trailing whitespace and null bytes before passing. If the response is empty, skip the prompt and return an empty audit log. |
[EVIDENCE_SET] | The complete set of authorized source passages with their canonical reference IDs. This is the ground truth against which every citation is checked. | {"ref:42": "Smith et al. (2024) report a 35% latency reduction in v2.1.", "ref:17": "The 2023 benchmark shows 12ms p50."} | Must be a valid JSON object mapping reference IDs to full source text. Reject if any key is missing or any value is an empty string. Validate JSON parse before prompt assembly. |
[CITATION_PATTERN] | A regex or description of the citation format used in the response. Tells the model how to locate citation markers in the text. | "\[ref:\d+\]" | Must be a non-empty string. Test against a known-good citation sample before use. If the pattern matches zero citations in [RESPONSE_TEXT], the prompt should return an empty audit log rather than failing. |
[ABSTENTION_MARKER] | The placeholder text to insert when a hallucinated citation is removed and no replacement exists. Prevents broken sentence fragments. | "[citation not found]" | Must be a non-empty string. Avoid markers that could be confused with real content. Do not use empty string unless downstream systems explicitly handle null citations. |
[CONFIDENCE_THRESHOLD] | The minimum similarity score (0.0 to 1.0) required to consider a citation grounded in the evidence set. Citations below this threshold are flagged as hallucinated. | 0.7 | Must be a float between 0.0 and 1.0. Values below 0.5 produce high false-positive rates. Values above 0.95 may miss paraphrased but valid citations. Default to 0.7 if not specified. |
[OUTPUT_SCHEMA] | The expected JSON structure for the repaired response and audit log. Ensures the model returns machine-readable output. | {"repaired_text": "string", "audit_log": [{"citation": "string", "status": "removed|replaced|verified", "reason": "string"}]} | Must be a valid JSON schema string or object. Validate that the schema includes at minimum a repaired_text field and an audit_log array. Reject schemas that omit the audit trail. |
[MAX_CITATIONS] | The maximum number of citations to process in a single prompt call. Prevents token overflow on long responses with dense citations. | 50 | Must be a positive integer. If [RESPONSE_TEXT] contains more citations than this limit, split into multiple prompt calls and merge audit logs. Default to 50 if not specified. |
Implementation Harness Notes
How to wire the hallucinated citation removal prompt into a production RAG pipeline with validation, retries, and audit logging.
This prompt is designed to sit as a post-generation safety net in your RAG pipeline, immediately after the model produces an answer with citations and before that answer reaches the user or a database. The harness should receive three inputs: the original model-generated text containing citations, the complete set of retrieved source chunks with their identifiers, and a configurable similarity threshold for matching claims to evidence. The prompt is stateless and idempotent—running it twice on the same input should produce the same hallucination audit log and cleaned output, which makes it safe for retry loops.
Wire the prompt into an application function that first extracts all citation markers from the model output using a regex pattern appropriate to your citation format (e.g., \[\d+\] for numeric, \(Author, Year\) for parenthetical). Pass the extracted citations, the full text, and the source evidence set into the prompt template. On the response, parse the JSON output into two structures: a cleaned text with hallucinated citations removed or replaced with [CITATION NOT FOUND] markers, and a hallucination audit log array containing each flagged citation, its claimed source text, the match score against the evidence set, and the action taken (removed, replaced, or retained). Validate that every citation in the cleaned output has a corresponding entry in the audit log before proceeding.
Implement a retry strategy with a maximum of two additional attempts if the model returns malformed JSON or if the audit log contains citations marked as uncertain. On retry, include the previous failure reason in the [CONSTRAINTS] block to guide the model toward a correctable output. Log every invocation—including the original text, the evidence set hash, the cleaned output, and the full audit log—to an append-only store for debugging and compliance. For high-risk domains such as legal or medical applications, route any output where more than 5% of citations were removed to a human review queue before publication. Avoid running this prompt on streaming outputs mid-stream; always accumulate the full response first to prevent partial citation analysis that could miss context-dependent attributions.
Expected Output Contract
Fields, types, and validation rules for the hallucinated citation removal output. Use this contract to parse the model response, run automated checks, and decide whether to accept, retry, or escalate.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
cleaned_text | string | Must not contain any citation marker or reference ID not present in the provided [SOURCE_CORPUS]. Parse check: extract all citation markers and confirm each resolves to a [SOURCE_CORPUS] entry. | |
hallucination_audit | array of objects | Each object must have keys: removed_citation (string), reason (enum: no_source_match | fabricated_id | unsupported_claim), replacement_action (enum: removed | replaced_with_abstention). Array length must equal count of removed citations. | |
hallucination_audit[].removed_citation | string | Must exactly match the citation string that was removed from the original output. Null or empty string not allowed. | |
hallucination_audit[].reason | enum string | Must be one of: no_source_match, fabricated_id, unsupported_claim. Schema check: reject any value outside this set. | |
hallucination_audit[].replacement_action | enum string | Must be one of: removed, replaced_with_abstention. If replaced_with_abstention, the cleaned_text must contain an abstention marker at that position. | |
abstention_markers | array of strings | If present, each marker string must appear in cleaned_text exactly once. Parse check: count occurrences of each marker in cleaned_text; duplicates indicate insertion error. | |
processing_notes | string or null | If non-null, must not exceed 500 characters. Null allowed when no edge cases encountered. Approval required if notes indicate ambiguous source matching. | |
confidence_score | number | Float between 0.0 and 1.0. If below 0.7, escalate for human review. Null allowed when model cannot estimate confidence. |
Common Failure Modes
What breaks first when removing hallucinated citations and how to guard against it.
False Negatives: Real Citations Flagged as Hallucinated
What to watch: The model incorrectly marks a valid citation as hallucinated because the source text uses different phrasing or the evidence chunk is too short to contain the full context. This erodes trust in the audit log and can remove legitimate attributions. Guardrail: Require semantic match verification, not just string overlap. Include a 'likely valid but unconfirmed' category in the output schema instead of a binary hallucinated/valid flag. Always surface borderline cases for human review.
Partial Match Over-Confidence
What to watch: The model treats a weak partial match as sufficient evidence, keeping a citation that is substantially fabricated. For example, a source mentions a company name but says nothing about the specific claim attributed to it. Guardrail: Add an explicit 'evidence sufficiency' check in the prompt that requires the cited passage to contain the core factual claim, not just overlapping entities. Output a sufficiency score per citation and set a minimum threshold before accepting a citation as valid.
Abstention Marker Proliferation
What to watch: The model over-corrects by replacing too many citations with abstention markers like '[citation needed]' or '[unverified]', leaving the output riddled with gaps that make it useless for end users. Guardrail: Constrain abstention to claims that are both unsupported and material. Provide a materiality threshold in the prompt: only flag claims whose removal would change the answer's meaning. Output a count of abstentions and fail the repair if it exceeds a configurable limit.
Audit Log Drift from Repaired Output
What to watch: The hallucination audit log describes removals or replacements that don't match what actually changed in the repaired output. The log says a citation was removed, but it's still present, or vice versa. Guardrail: Add a post-repair reconciliation step that diffs the original and repaired outputs and verifies each audit log entry against the actual changes. Reject the repair if the log and output are inconsistent, and retry with explicit alignment instructions.
Evidence Set Exhaustion Under Load
What to watch: When the provided evidence set is large, the model skips chunks or fails to search thoroughly, missing valid sources and incorrectly flagging citations as hallucinated. This is especially common with long context windows where attention dilutes. Guardrail: Chunk the evidence set and run citation verification in parallel per chunk, then merge results. If the evidence set exceeds a token budget, pre-filter to the most relevant chunks before running the hallucination check rather than dumping everything into one prompt.
Citation Format Corruption During Repair
What to watch: The repair process alters citation formatting, breaks inline reference numbering, or introduces malformed markers that downstream parsers can't handle. The output is factually correct but structurally broken. Guardrail: Include a format preservation constraint in the prompt that requires the repaired output to maintain the exact citation syntax of the original. Run a schema or regex validator on the repaired output before accepting it, and reject repairs that introduce format regressions.
Evaluation Rubric
Criteria for testing the Hallucinated Citation Removal prompt before shipping. Each row defines a pass standard, a failure signal, and a concrete test method to validate output quality.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Hallucinated citation removal | All citations with no matching source in [SOURCE_CORPUS] are removed from [INPUT_TEXT] | A citation ID present in the output does not exist in [SOURCE_CORPUS] | Parse output citations; assert set(output_citation_ids).issubset(set(source_corpus_ids)) |
Abstention marker insertion | Every removed citation is replaced with [ABSTENTION_MARKER] in the exact position of removal | A removed citation leaves no marker, or the marker text does not match [ABSTENTION_MARKER] | Count removed citations in audit log; assert count of [ABSTENTION_MARKER] in output text equals removed count |
Surrounding text preservation | Text before and after a removed citation remains identical to [INPUT_TEXT] except for the marker replacement | Adjacent words are deleted, altered, or rephrased during citation removal | Diff [INPUT_TEXT] against output with citations and markers masked; assert no unexpected character changes |
Audit log completeness | [AUDIT_LOG] contains one entry per citation in [INPUT_TEXT] with fields: citation_id, status, matched_source_id, action_taken | A citation from [INPUT_TEXT] is missing from [AUDIT_LOG] or a required field is null for a non-abstained citation | Validate [AUDIT_LOG] against JSON schema; assert len(audit_log) equals count of citations in [INPUT_TEXT] |
Audit log status accuracy | Each audit log entry has status 'removed' if no source match found, 'retained' if match found | A citation with a valid source match is marked 'removed', or vice versa | For each audit log entry, cross-reference matched_source_id against [SOURCE_CORPUS]; assert status matches presence or absence of source |
No new citations introduced | Output contains zero citation markers that were not present in [INPUT_TEXT] | A new citation ID appears in the output that is not in the original input citation set | Parse output citation IDs; assert set(output_citation_ids).issubset(set(input_citation_ids)) |
Confidence threshold compliance | No citation with confidence below [CONFIDENCE_THRESHOLD] is retained in output | A retained citation has a confidence score in [AUDIT_LOG] below [CONFIDENCE_THRESHOLD] | Filter audit log for status 'retained'; assert all confidence scores >= [CONFIDENCE_THRESHOLD] |
Output schema validity | Output is valid JSON matching [OUTPUT_SCHEMA] with all required fields present and correctly typed | JSON parse fails, required field is missing, or field type does not match schema | Validate output against [OUTPUT_SCHEMA] using JSON Schema validator; assert validation passes with no errors |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Start with the base prompt and a small evidence set (5–10 sources). Use a frontier model with strong instruction following. Skip the audit log initially—just ask the model to remove unsupported citations and mark gaps with [CITATION NEEDED].
codeRemove any citation that does not match a source in [EVIDENCE_SET]. Replace removed citations with [CITATION NEEDED]. Return only the cleaned text.
Watch for
- Model deleting citations that are actually supported but phrased differently
- Over-removal when evidence set uses different terminology than the output
- No way to verify what was removed without the audit log

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us