This prompt is designed for compliance officers, quality engineers, and AI platform teams who need to verify that every inline citation in a generated answer is traceable to a real source document captured in the production trace. The primary job-to-be-done is producing a structured alignment scorecard that maps each citation to a specific trace event ID, confirms whether the cited content actually supports the claim, and flags misalignments for remediation. Use this prompt when you are operating a Retrieval-Augmented Generation (RAG) system in a regulated domain, preparing for an external audit, or establishing a continuous grounding quality metric. The ideal user has access to a full observability trace that includes the final generated output, the list of retrieved source documents, and their associated trace span or event IDs.
Prompt
Citation-to-Source Alignment Audit Prompt

When to Use This Prompt
Define the job, reader, and constraints for the Citation-to-Source Alignment Audit Prompt.
Do not use this prompt for real-time guardrailing or blocking of model outputs; it is a post-hoc diagnostic and audit tool, not a low-latency safety classifier. It is also inappropriate for evaluating the semantic quality or helpfulness of an answer—its scope is strictly limited to citation-to-source alignment. The prompt requires structured input: a generated answer containing inline citations, a set of retrieved source documents with unique identifiers, and the trace event IDs that link retrieval events to the final generation. Without these inputs, the alignment audit cannot produce a reliable scorecard. The output is a machine-readable JSON report, making it suitable for integration into automated evaluation pipelines, compliance dashboards, or periodic audit workflows.
Before running this prompt, ensure your trace data is complete and that citation markers in the generated answer are parseable. If your system uses numeric citation brackets like [1], [2], or author-date references, you must include a mapping to trace event IDs in the input context. The prompt will flag citations that point to missing documents, documents that were retrieved but not used, and claims that cite a source but are not actually supported by its content. After receiving the alignment scorecard, route any critical misalignments to a human reviewer for final determination, especially in high-risk domains like healthcare, legal, or finance. Do not treat the model's alignment judgment as ground truth without human verification when compliance consequences are material.
Use Case Fit
This audit prompt is designed for compliance and quality teams who need to verify that every inline citation in a generated answer maps to a real source document and supports the claim. It is not a general-purpose hallucination detector.
Good Fit: Structured RAG Traces
Use when: You have production traces containing both the final generated answer with inline citations and the full retrieved context with document IDs. The prompt excels at mapping citation markers to trace event IDs and checking content alignment. Guardrail: Ensure your tracing system captures retrieval event IDs and document spans before invoking this audit.
Bad Fit: Unstructured or Missing Traces
Avoid when: The generated text lacks formal citation markers, or the trace does not contain the original retrieved documents. This prompt cannot invent missing evidence. Guardrail: Implement a pre-check that validates the presence of citation markers and trace document fields before running the alignment audit.
Required Inputs
What you must provide: A generated answer with inline citations, a trace log containing retrieval events with document IDs and full text spans, and a mapping between citation markers and retrieval event IDs. Guardrail: Use a structured trace format (e.g., OpenTelemetry with custom attributes) to ensure consistent input parsing.
Operational Risk: False Positives in Paraphrasing
What to watch: The model may flag a citation as misaligned when the generated text paraphrases the source rather than quoting it verbatim. This can inflate misalignment counts. Guardrail: Include a semantic similarity threshold in the evaluation rubric and treat low-confidence misalignments as warnings, not failures.
Operational Risk: Citation Format Variability
What to watch: Inconsistent citation formats (e.g., [1], [doc_1], (Source A)) can cause the prompt to miss valid citations or misattribute them. Guardrail: Normalize citation formats before the audit step using a preprocessing function that maps all citation styles to a canonical trace event ID.
When to Escalate to Human Review
What to watch: The scorecard flags a misalignment, but the source document is ambiguous, highly technical, or contains conflicting information. Guardrail: Route all high-severity misalignments and low-confidence alignment scores to a human review queue with the full trace context attached.
Copy-Ready Prompt Template
A reusable prompt template for auditing citation-to-source alignment in RAG traces, ready to copy and adapt.
This prompt template is designed to be dropped into an evaluation harness or a manual review workflow. It instructs the model to compare every inline citation in a generated answer against the source documents captured in the production trace, producing a structured scorecard. The template uses square-bracket placeholders for all variable inputs, making it straightforward to wire into a CI/CD pipeline, a monitoring job, or a human-in-the-loop review queue.
textYou are an auditor reviewing a generated answer and its full production trace. Your task is to verify that every inline citation in the answer maps to a real source document present in the trace and that the cited content actually supports the claim it is attached to. ## INPUT **Generated Answer:** [GENERATED_ANSWER] **Trace Events (JSON array of retrieval and generation steps):** [TRACE_EVENTS] **Source Documents (full text keyed by document ID):** [SOURCE_DOCUMENTS] ## OUTPUT SCHEMA Return a valid JSON object with the following structure: { "alignment_scorecard": { "total_citations": <integer>, "aligned_citations": <integer>, "misaligned_citations": <integer>, "unverifiable_citations": <integer>, "overall_alignment_score": <float between 0.0 and 1.0> }, "misalignment_instances": [ { "citation_text": "<the exact citation marker or text from the answer>", "claimed_source_id": "<the document ID the citation points to>", "trace_event_id": "<the trace event ID where this citation was generated>", "failure_type": "<MISSING_SOURCE | CONTENT_MISMATCH | FABRICATED_CITATION | STALE_SOURCE | AMBIGUOUS_ATTRIBUTION>", "failure_description": "<specific explanation of what went wrong>", "cited_content": "<the relevant excerpt from the source document, or null if source missing>", "claim_made": "<the claim the citation was supposed to support>", "severity": "<CRITICAL | MAJOR | MINOR>" } ], "unverifiable_notes": "<explanation for any citations that could not be verified due to trace gaps or missing documents>" } ## CONSTRAINTS 1. Extract every inline citation from the generated answer. Citations may appear as bracketed numbers [1], [2], parenthetical references (Source A), or inline links. 2. For each citation, locate the corresponding source document in [SOURCE_DOCUMENTS] using the document ID referenced in the trace event. 3. Compare the claim the citation is attached to against the full text of the source document. The citation is aligned only if the source document explicitly supports the specific claim. 4. Classify each misalignment using the failure types defined in the output schema. 5. If a citation references a document ID not present in [SOURCE_DOCUMENTS], classify it as FABRICATED_CITATION. 6. If the source document exists but does not contain information supporting the claim, classify it as CONTENT_MISMATCH. 7. If the source document exists but is timestamped before a known factual update relevant to the claim, classify it as STALE_SOURCE. 8. If the trace does not contain enough information to verify a citation, mark it as unverifiable and explain why in unverifiable_notes. 9. Assign severity: CRITICAL for safety, legal, or compliance-impacting misalignments; MAJOR for factual errors with user impact; MINOR for imprecise but not misleading attributions. 10. Do not invent source content. Only use the provided [SOURCE_DOCUMENTS]. ## RISK LEVEL [RISK_LEVEL] ## EXAMPLES [EXAMPLES]
To adapt this template, replace each square-bracket placeholder with data from your production trace system. The [TRACE_EVENTS] placeholder expects a JSON array of trace spans, including retrieval calls, reranking steps, and generation events with their associated document IDs. The [SOURCE_DOCUMENTS] placeholder should contain the full text of every document referenced in the trace, keyed by the same document IDs. The [RISK_LEVEL] placeholder accepts values like HIGH, MEDIUM, or LOW and can be used to adjust the strictness of severity classification. The [EXAMPLES] placeholder should be populated with a few representative citation alignment examples, including both aligned and misaligned cases, to calibrate the model's judgment. For production use, always validate the output JSON against the schema before ingesting it into dashboards or alerting systems. If the workflow involves regulated content, route CRITICAL severity findings to a human reviewer before taking automated action.
Prompt Variables
Required inputs for the Citation-to-Source Alignment Audit Prompt. Each placeholder must be populated from production trace data before the prompt is executed. Missing or malformed inputs are the most common cause of false negatives in alignment scoring.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[GENERATED_ANSWER] | The full generated text containing inline citations to audit | According to the 2024 report [doc_12], revenue increased by 14% [doc_12]. | Must be non-empty string. Strip markdown fences before passing. Validate that citation markers exist; if none found, prompt will return empty alignment report. |
[TRACE_EVENT_LOG] | Complete trace of retrieval events with event IDs, timestamps, and retrieved document spans | {"events": [{"event_id": "ret_01", "doc_id": "doc_12", "content": "Revenue grew 14% YoY..."}]} | Must be valid JSON array. Each event requires event_id, doc_id, and content fields. Missing content field causes null alignment for that event. Validate schema before prompt execution. |
[CITATION_FORMAT] | Regex or pattern describing how citations appear in the generated answer | "\[doc_\d+\]" | Must be a valid regex string. Test against [GENERATED_ANSWER] before audit. Incorrect pattern causes all citations to be treated as unlinked. Escape backslashes for JSON transport. |
[SOURCE_DOCUMENTS] | Full text of all source documents referenced in the trace, keyed by doc_id | {"doc_12": "Annual Report 2024: Revenue grew 14% YoY to $2.3B..."} | Must be valid JSON object with doc_id keys matching [TRACE_EVENT_LOG] references. Missing documents cause false misalignment flags. Validate key coverage against trace event doc_ids. |
[CONFIDENCE_THRESHOLD] | Minimum semantic similarity score to consider a citation aligned to source content | 0.75 | Float between 0.0 and 1.0. Values below 0.6 increase false positives; above 0.9 increase false negatives. Default 0.75 if not specified. Validate range before prompt execution. |
[OUTPUT_SCHEMA] | Expected JSON schema for the alignment scorecard output | {"scorecard": {"total_citations": "int", "aligned": "int", "misaligned": "int", "misalignment_instances": [{"citation": "string", "claimed_doc_id": "string", "trace_event_id": "string", "reason": "string"}]}} | Must be valid JSON Schema or TypeScript interface. Prompt uses this to structure output. Validate parseability before execution. Schema mismatch causes repair retries. |
[ABSTENTION_POLICY] | Rule for handling citations that reference documents with insufficient content for alignment verification | "flag_as_unverifiable" | Must be one of: flag_as_unverifiable, exclude_from_score, treat_as_misaligned. Controls denominator in alignment rate calculation. Validate enum membership before prompt execution. |
Common Failure Modes
Citation-to-source alignment audits fail in predictable ways. These cards cover the most common failure modes and how to build guardrails that catch them before they reach a compliance reviewer.
Citation Points to Wrong Document
What to watch: The generated answer cites Source A, but the trace shows the claim was actually drawn from Source B. This misattribution creates a false audit trail. Guardrail: Require the audit prompt to return the exact trace event ID and passage span for every citation. Flag any citation where the trace-retrieved passage does not contain the cited claim.
Citation Exists but Claim Is Unsupported
What to watch: The citation format is correct and points to a real document, but the cited passage does not actually support the claim made in the output. The model paraphrased beyond what the source says. Guardrail: Add a per-citation entailment check in the audit prompt. Require a binary supported/unsupported label with a short justification quoting the source span.
Fabricated Citation with Plausible Format
What to watch: The model generates a citation that looks real—correct author name, plausible title, valid format—but no matching document exists in the trace. This is the most dangerous failure mode for compliance. Guardrail: Prepend the audit with a strict existence check. Every cited document ID must resolve to a trace event. Return a separate list of orphan citations with no trace match.
Citation Granularity Mismatch
What to watch: A single citation is placed at the end of a paragraph covering multiple claims, but the cited source only supports one of them. The reader assumes all claims are grounded. Guardrail: Require claim-level citation alignment. The audit prompt should extract atomic claims first, then match each claim to its closest supporting passage. Flag any claim without a direct match.
Stale Trace Data Used for Audit
What to watch: The audit runs against a trace that was truncated, sampled, or logged after retrieval but before generation. Missing trace spans make legitimate citations appear unsupported. Guardrail: Validate trace completeness before running the audit. Check that retrieval events, context window contents, and final output are all present. Abort with a trace-incomplete error if spans are missing.
Audit Prompt Itself Hallucinates Alignment
What to watch: The LLM running the audit may fabricate alignment between a claim and a source when the connection is weak, overstating support to produce a clean scorecard. Guardrail: Require the audit output to include verbatim source quotes for every supported claim. If the quote does not contain the claim's key entities or predicates, flag it as a weak match and escalate for human review.
Evaluation Rubric
Use this rubric to test the Citation-to-Source Alignment Audit Prompt before shipping. Each criterion targets a specific failure mode in production citation alignment. Run these checks against a golden trace set with known misalignments.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Citation-to-Trace-Event Mapping | Every inline citation in [OUTPUT] maps to exactly one trace event ID from [TRACE_DATA] | Citation references a trace event ID not present in [TRACE_DATA] or maps to null | Parse all citation markers from [OUTPUT]; cross-reference each against the trace event ID list in [TRACE_DATA]; flag orphans |
Claim-Source Content Alignment | Each cited claim in [OUTPUT] is directly supported by the content of its mapped source document span | Cited claim contradicts, exaggerates, or fabricates content not present in the source span | For each citation pair, extract the claim text and the source span text; run a semantic entailment check; flag pairs where entailment score is below [ENTAILMENT_THRESHOLD] |
Misattribution Detection | Zero citations point to a source that exists but does not contain the cited claim | Citation points to a real document in [TRACE_DATA] but the document content does not support the claim | For each citation, verify the source document content contains the claim's key entities and predicates; flag mismatches |
Missing Citation Flagging | All factual claims requiring evidence have an inline citation | A factual claim appears in [OUTPUT] with no citation marker and no source grounding in [TRACE_DATA] | Extract all atomic claims from [OUTPUT]; check each for a citation marker; flag uncited factual claims |
Scorecard Completeness | Output scorecard includes alignment_score, total_citations, aligned_count, misaligned_count, and misalignment_instances array | Scorecard is missing required fields or misalignment_instances is empty when misaligned_count is greater than 0 | Validate [OUTPUT_SCHEMA] compliance with JSON schema validator; confirm misaligned_count equals length of misalignment_instances array |
Trace Event ID Precision | Each misalignment instance includes the specific trace event ID and source document identifier | Misalignment instance references a trace event ID at the wrong granularity or omits the document identifier | Check each misalignment_instances entry for trace_event_id and source_document_id fields; verify IDs exist in [TRACE_DATA] |
False Positive Resistance | Scorecard does not flag correctly aligned citations as misaligned | A citation that accurately reflects its source is marked as misaligned | Run against a golden set of 10 known-correct citation pairs; confirm aligned_count matches expected and misaligned_count is 0 |
Edge Case: Multiple Sources per Claim | Claims supported by multiple sources are flagged only if no single source fully supports the claim | A claim with partial support across sources is incorrectly marked as aligned when no single source contains the full claim | Test with a claim that requires stitching from two sources; verify it is flagged as misaligned with a note about distributed evidence |
Implementation Harness Notes
How to wire the Citation-to-Source Alignment Audit Prompt into a production RAG observability pipeline.
This prompt is designed to run as a post-hoc audit step, not as part of the real-time generation path. It consumes a structured trace object containing the final generated answer, its inline citations, and the full set of retrieved source documents with their trace event IDs. The ideal integration point is within an asynchronous evaluation pipeline triggered after a user session completes, a batch of traces is collected, or a compliance review is initiated. Do not run this prompt synchronously before returning an answer to the user; the latency and cost are justified only for offline quality assurance, regulatory review, or systematic hallucination monitoring.
To wire this into an application, build a trace pre-processor that extracts the required fields from your observability store (e.g., LangSmith, Arize, or a custom trace database) and assembles them into the [TRACE_INPUT] placeholder. The input must include: the full generated text with citation markers in situ, a mapping of citation IDs to source document identifiers, and the complete text of each retrieved source document. The model choice should prioritize strong reasoning and structured output capabilities—GPT-4o or Claude 3.5 Sonnet are appropriate defaults. Set temperature=0 for deterministic scoring. Implement a retry wrapper with up to 3 attempts for malformed JSON responses, using a repair prompt from the Output Repair and Validation Prompts pillar if the initial parse fails. Log every audit result with the trace ID, timestamp, model version, and prompt version to maintain an audit trail for governance reviews.
After receiving the alignment scorecard, validate the output programmatically before accepting it. Confirm that every misalignment instance references a real trace event ID present in the input, that the overall alignment score is a float between 0.0 and 1.0, and that the number of cited claims matches the number of evaluated claims. If the score falls below a defined threshold (e.g., 0.95 for regulated use cases), route the trace to a human review queue with the misalignment instances pre-populated. For high-volume pipelines, consider sampling traces by risk tier rather than auditing 100% of traffic. Avoid the temptation to use this prompt as a real-time guardrail—its strength is in systematic, evidence-backed audit, not in blocking responses under latency pressure.
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
Use the base prompt with a single trace and lighter validation. Replace the strict JSON output schema with a simpler markdown table to speed up iteration. Focus on getting the alignment logic right before adding trace event IDs and severity classifications.
codeAnalyze the following trace and output a markdown table with columns: Citation, Source Document, Claim, Alignment (Supported/Unsupported/Partial). Trace: [TRACE_JSON]
Watch for
- Missing schema checks can hide misalignment patterns
- Overly broad instructions may produce vague alignment judgments instead of specific span references
- Without trace event IDs, findings are harder to action for engineering follow-up

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