Inferensys

Prompt

Citation and Source Attribution Adherence Prompt

A practical prompt playbook for using Citation and Source Attribution Adherence Prompt 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

Understand the job-to-be-done, the ideal user, and the boundaries of the Citation and Source Attribution Adherence Prompt.

This prompt is an LLM judge designed for RAG system builders who need to verify that generated answers cite sources correctly, quote within defined limits, and attribute every factual claim to evidence. It is not a prompt for generating answers; it is an evaluation prompt that grades another model's output against a set of source documents. The primary job-to-be-done is automated, model-graded evaluation of citation quality before answers reach users. You should use this prompt when you are shipping a RAG product and need to catch hallucinated sources, missing citations, and format violations at scale, without relying solely on manual spot checks.

The ideal user is an AI engineer, evaluation lead, or product developer responsible for RAG output quality. Required context includes the original user query, the full generated answer, and the complete set of source documents provided to the generation model. The prompt produces a structured citation compliance report with missing-citation flags, hallucinated-source detection, and format adherence checks. This output can be wired into a CI/CD pipeline, a regression test suite, or an online evaluation harness that gates answers before they are shown to users. For high-stakes domains such as healthcare, legal, or finance, the compliance report should trigger human review rather than acting as the sole gatekeeper.

Do not use this prompt when you need to evaluate the factual accuracy of claims against ground truth outside the provided sources, when you are grading the stylistic quality of prose, or when the generation model had access to tools or retrieval that are not fully represented in the source document list. This prompt also cannot detect subtle plagiarism where a claim is supported by a source but the wording is too close to the original without quotation marks—it checks for explicit citation markers and quote formatting, not semantic similarity of phrasing. If you need to verify that every sentence is grounded in evidence regardless of citation format, pair this prompt with a separate groundedness evaluation judge. After reading this section, you should have a clear picture of whether this prompt fits your evaluation workflow. Next, review the prompt template to see the exact instructions and output schema.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Citation and Source Attribution Adherence Prompt delivers value and where it introduces risk.

01

Good Fit: RAG Answer Verification

Use when: you need to verify that a generated answer is fully grounded in the provided context chunks. Guardrail: Pair this prompt with a strict quote-extraction step to prevent the judge from hallucinating source matches.

02

Good Fit: Pre-Release QA Gate

Use when: shipping a new RAG pipeline version and you need an automated pass/fail check on citation accuracy. Guardrail: Run against a golden dataset of known-correct attributions to calibrate the judge's strictness before blocking the release.

03

Bad Fit: Creative or Opinion Content

Avoid when: evaluating outputs that synthesize ideas or provide subjective analysis without explicit source mapping. Guardrail: Use a groundedness evaluation prompt instead, which checks factual consistency without requiring sentence-level citations.

04

Bad Fit: Ambiguous Authorship

Avoid when: the source material itself lacks clear provenance or the model is expected to combine common knowledge with retrieved text. Guardrail: Implement a pre-filter that only runs citation checks when source documents have stable identifiers and clear boundaries.

05

Required Inputs

Risk: The prompt fails silently if the full source context is truncated or missing. Guardrail: Always pass the complete, unsummarized context chunks with stable IDs. Validate that the context payload is non-empty and contains the expected number of documents before invoking the judge.

06

Operational Risk: Judge Hallucination

Risk: The LLM judge may flag citations as missing when they exist or invent phantom violations. Guardrail: Implement a two-stage verification where flagged violations are spot-checked by a second judge or a simple string-match script before surfacing to the user.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A production-ready prompt for evaluating whether a generated answer faithfully cites and attributes claims to the provided source documents.

This prompt template acts as an automated judge for your Retrieval-Augmented Generation (RAG) pipeline. Its job is to compare a generated answer against the source documents it was supposed to use, producing a structured compliance report. The report flags missing citations, identifies claims that hallucinate or misrepresent the source material, and verifies that direct quotes stay within defined length limits. Use this as a gate in your CI/CD pipeline or as a continuous evaluation monitor to catch attribution failures before your users do.

text
You are an expert citation auditor for a RAG system. Your task is to evaluate the generated answer against the provided source documents and produce a strict compliance report.

## INPUT
**Source Documents:**
[SOURCE_DOCUMENTS]

**Generated Answer:**
[GENERATED_ANSWER]

## EVALUATION CRITERIA
1. **Claim Verification:** Break the answer into discrete factual claims. For each claim, determine if it is directly supported by the source documents, contradicted by them, or not found (hallucinated).
2. **Citation Format Adherence:** Check if citations follow the required format: [CITATION_FORMAT]. Flag any malformed citations.
3. **Quote Length Compliance:** Identify any direct quotes from the source material. Flag any quote that exceeds the maximum length of [MAX_QUOTE_LENGTH] words.
4. **Source Attribution Accuracy:** For every citation, verify that the cited source document actually contains the information being attributed to it. Flag any misattributions.

## OUTPUT_SCHEMA
You must respond with a single JSON object conforming to this schema:
{
  "overall_compliance": "PASS" | "FAIL",
  "claim_analysis": [
    {
      "claim_text": "string",
      "verdict": "SUPPORTED" | "CONTRADICTED" | "HALLUCINATED",
      "source_evidence": "string or null",
      "citation_used": "string or null"
    }
  ],
  "citation_format_violations": [
    {
      "malformed_citation": "string",
      "issue": "string"
    }
  ],
  "quote_length_violations": [
    {
      "quote_snippet": "string",
      "word_count": integer,
      "source_document": "string"
    }
  ],
  "misattributions": [
    {
      "citation": "string",
      "claimed_fact": "string",
      "actual_source_content": "string"
    }
  ]
}

## CONSTRAINTS
- If no source documents are provided, automatically FAIL the answer and flag all claims as HALLUCINATED.
- If the answer states it cannot answer the question, verify that the sources indeed lack the information. If they do, the verdict is PASS.
- Do not penalize minor grammatical differences between a claim and the source text if the semantic meaning is identical.

To adapt this template, replace the square-bracket placeholders with your data. [SOURCE_DOCUMENTS] should contain the full text of retrieved passages, each with a unique identifier. [GENERATED_ANSWER] is the raw output from your LLM. [CITATION_FORMAT] should be a precise description of your expected format, such as [Author, Year] or [Source ID]. [MAX_QUOTE_LENGTH] is an integer representing your word limit for direct quotes. Before deploying, run this prompt against a golden dataset of 50-100 examples with known citation errors to calibrate its strictness. If the judge is too lenient on hallucinated claims, add few-shot examples of borderline cases to the prompt. Always log the full JSON output for debugging false positives and negatives in production.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Citation and Source Attribution Adherence Prompt. Each placeholder 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 citation compliance reports.

PlaceholderPurposeExampleValidation Notes

[GENERATED_TEXT]

The model output under review for citation compliance

According to the 2023 NIST report, AI incidents rose 30% year-over-year.

Required. Must be non-empty string. Truncate if longer than model context window minus prompt overhead. Null or empty input should abort evaluation with INPUT_MISSING error.

[SOURCE_DOCUMENTS]

The retrieved or provided evidence set the output should cite from

["doc_1": "NIST AI 100-1: AI Risk Management Framework...", "doc_2": "Stanford HAI 2024 Index Report..."]

Required. Must be a valid JSON array of objects with id and content fields. Empty array is allowed and should trigger a NO_SOURCES_AVAILABLE flag in the report. Validate structure before prompt assembly.

[CITATION_FORMAT]

The expected citation style the output must follow

inline-parenthetical, footnote-numeric, bracket-id, or natural-language

Required. Must match one of the supported enum values. Unrecognized formats should cause prompt assembly to fail with UNSUPPORTED_FORMAT error. Default to bracket-id if not specified but log a warning.

[QUOTE_LIMIT_PERCENT]

Maximum percentage of output allowed to be direct quotes from sources

15

Optional. Must be integer between 0 and 100. If null or omitted, default to 20. Values below 5 may produce excessive false positives for short outputs. Validate range before injection.

[REQUIRED_ATTRIBUTION_FIELDS]

Fields that must be present in every citation for compliance

["source_id", "page_number", "section_title"]

Optional. Must be a valid JSON array of strings. If null or omitted, default to ["source_id"]. Empty array means no field-level attribution check. Validate field names against SOURCE_DOCUMENTS schema.

[HALLUCINATION_DETECTION_MODE]

Controls how aggressively the prompt flags unsupported claims

strict, moderate, or lenient

Required. Must match one of the supported enum values. Strict mode flags any claim without explicit source support. Lenient mode allows reasonable inference. Moderate is default. Invalid values should abort with INVALID_MODE error.

[OUTPUT_SCHEMA_VERSION]

Schema version for the compliance report output format

v2

Optional. Must match a known schema version string. If null or omitted, default to latest stable version. Mismatched versions should trigger a SCHEMA_VERSION_WARNING but not abort. Validate against known schema registry.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the citation verification prompt into a RAG evaluation pipeline with validation, retries, and human review gates.

The Citation and Source Attribution Adherence Prompt is designed to operate as a post-generation evaluation step within a RAG pipeline. After your primary model generates an answer with citations, this prompt acts as an LLM judge that inspects the output against the provided source documents. The harness should pass the generated answer, the list of source chunks (with IDs), and any citation format rules as inputs to this prompt. The output is a structured compliance report—not a corrected answer—so the harness must decide what to do with the report: flag for review, trigger a retry, or pass the answer downstream.

Wire the prompt into your application by calling it synchronously after answer generation and before returning the result to the user. Use a structured output API (such as OpenAI's response_format with a JSON schema or function calling) to enforce the compliance report schema. The report should include fields like overall_compliance_score, missing_citation_flags (list of claims without source IDs), hallucinated_source_flags (cited source IDs not present in the input), quote_length_violations, and format_adherence_checks. Implement a validation layer that parses this JSON and checks for schema conformance—if the judge itself returns malformed JSON, retry once with a stricter schema instruction. For high-stakes domains (legal, medical, financial), route any report with overall_compliance_score below a configurable threshold (e.g., 0.9) to a human review queue rather than auto-retrying, because retry loops can mask systemic hallucination patterns.

Log every evaluation result—including the input sources, generated answer, compliance report, and final disposition—to your observability platform. This trace data is essential for debugging citation drift over time and for calibrating the judge's thresholds against human spot checks. Avoid using this prompt as the sole gatekeeper in production without periodic human calibration: sample a percentage of passed outputs and manually verify that the judge isn't missing subtle misattributions or over-penalizing acceptable paraphrasing. Start with a strict threshold and loosen it only after reviewing false-positive patterns in the human calibration data.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, format, and validation rules for the citation compliance report. Use this contract to build a downstream parser, validator, or eval harness that consumes the model output.

Field or ElementType or FormatRequiredValidation Rule

overall_compliance

object

Must contain status (pass/fail) and score (float 0.0-1.0). Score must equal (passing_claims / total_claims) if total_claims > 0, else 1.0.

overall_compliance.status

enum: pass | fail

Must be pass if score >= [PASS_THRESHOLD], else fail. Default threshold 0.95.

overall_compliance.score

float

Must be between 0.0 and 1.0 inclusive. Calculated as passing_claims / total_claims. Null if total_claims is 0.

claims

array of objects

Must be a JSON array. Minimum 0 items. Each item must match the claim object schema below. Empty array allowed if no claims detected.

claims[].claim_id

string

Must be unique within the claims array. Format: claim-{index} where index is 1-based integer matching array position.

claims[].claim_text

string

Must be a non-empty string. Should be the exact claim extracted from [OUTPUT_TEXT]. Truncation allowed if claim exceeds [MAX_CLAIM_LENGTH] characters.

claims[].source_attribution

object

Must contain source_id (string or null), citation_format (enum: inline | footnote | parenthetical | none), and citation_text (string or null).

claims[].source_attribution.source_id

string | null

If present, must match a source_id in [SOURCE_MATERIALS]. Null indicates no source cited. Hallucination check: flag if source_id not in provided sources.

claims[].source_attribution.citation_text

string | null

If source_id is not null, citation_text must be non-empty and contain a quote or reference locator. If source_id is null, citation_text must be null.

claims[].verification_result

enum: cited_correct | cited_incorrect | missing_citation | hallucinated_source | not_verifiable

cited_correct: source exists and supports claim. cited_incorrect: source exists but does not support claim. missing_citation: factual claim with no source. hallucinated_source: source_id not in [SOURCE_MATERIALS]. not_verifiable: claim cannot be checked against provided sources.

claims[].verification_detail

string

Must be non-empty. Brief explanation of verification result. For cited_correct, include quote or evidence location. For failures, describe mismatch or missing evidence.

claims[].quote_exceeds_limit

boolean

Must be true if cited text exceeds [MAX_QUOTE_LENGTH] characters from source. Else false. Triggers quote-length violation flag.

flagged_issues

array of objects

Must be an array. Each object has issue_type (enum: missing_citation | hallucinated_source | quote_too_long | format_violation | unsupported_claim), claim_id (string matching a claim in claims array), and detail (string).

flagged_issues[].issue_type

enum: missing_citation | hallucinated_source | quote_too_long | format_violation | unsupported_claim

Must be one of the listed enum values. missing_citation and hallucinated_source must reference a claim_id with corresponding verification_result.

flagged_issues[].claim_id

string

Must match a claim_id present in the claims array. Used to link issue to specific claim for downstream remediation.

flagged_issues[].detail

string

Must be non-empty. Human-readable description of the issue. Include specific evidence: expected source, actual citation, character count for quote violations.

format_adherence

object

Must contain citation_style (enum matching [REQUIRED_CITATION_STYLE] or unknown), style_violations (array of strings), and format_score (float 0.0-1.0).

format_adherence.citation_style

enum: inline | footnote | parenthetical | numeric | unknown

Must be detected style from output. Compare to [REQUIRED_CITATION_STYLE]. If mismatch, add to style_violations and reduce format_score.

format_adherence.style_violations

array of strings

Each string describes a specific format violation. Empty array if no violations. Examples: 'Missing bracket around citation', 'Footnote number not sequential', 'Citation style mismatch: expected inline, found footnote'.

format_adherence.format_score

float

Must be between 0.0 and 1.0. Calculated as 1.0 - (violation_count * [VIOLATION_PENALTY]). Default penalty 0.1. Floor at 0.0.

summary

object

Must contain total_claims (integer), passing_claims (integer), failing_claims (integer), missing_citation_count (integer), hallucinated_source_count (integer), and quote_violation_count (integer).

summary.total_claims

integer

Must equal length of claims array. Minimum 0.

summary.passing_claims

integer

Must equal count of claims where verification_result is cited_correct. Must be <= total_claims.

summary.failing_claims

integer

Must equal total_claims - passing_claims. Must be >= 0.

summary.missing_citation_count

integer

Must equal count of claims where verification_result is missing_citation.

summary.hallucinated_source_count

integer

Must equal count of claims where verification_result is hallucinated_source.

summary.quote_violation_count

integer

Must equal count of claims where quote_exceeds_limit is true.

PRACTICAL GUARDRAILS

Common Failure Modes

Citation and source attribution prompts fail in predictable ways. These are the most common failure modes when verifying RAG outputs, along with practical guardrails to catch them before they reach users.

01

Hallucinated Citations

What to watch: The model invents plausible-sounding citations that don't exist in the provided sources—fabricated author names, made-up page numbers, or entirely fictional document titles. This is the most dangerous failure mode because it looks authoritative while being completely ungrounded. Guardrail: Require exact string matching between cited text and source passages. Flag any citation whose quoted text doesn't appear verbatim in the retrieved context. Add a 'citation_exists_in_source' boolean field to your evaluation schema and fail any output where it's false.

02

Correct Source, Wrong Claim

What to watch: The model cites a real document but attributes a claim to it that the source never made. The citation looks valid—the document exists, the section exists—but the semantic content is misattributed. This often happens when the model conflates multiple sources or fills gaps with plausible inference. Guardrail: Implement claim-by-claim verification where each cited claim is independently checked against its source passage. Use a separate verification step that asks: 'Does this specific passage support this specific claim?' Require a yes/no/maybe judgment with a confidence score.

03

Over-Quoting Without Attribution

What to watch: The output copies large blocks of source text verbatim but fails to mark them as direct quotes or provide citations. This creates plagiarism risk and makes it impossible for reviewers to distinguish model synthesis from source copying. Guardrail: Add a quote-detection pass that compares output text against all source passages using substring matching. Flag any continuous span longer than a configurable threshold (e.g., 15 words) that matches a source but lacks quotation marks or a citation marker. Report the percentage of output text that is unmarked direct quotation.

04

Citation Format Drift

What to watch: The model starts with the correct citation format (e.g., bracketed numbers, author-date) but gradually drifts to inconsistent formats, partial citations, or vague references like 'as mentioned in the document.' This breaks downstream parsers and erodes user trust. Guardrail: Define a strict citation format schema with a regex pattern or grammar. Validate every citation in the output against this pattern. Include format adherence as a separate scoring dimension in your evaluation rubric. Add few-shot examples showing both correct and incorrect formats with explicit rejections of the incorrect ones.

05

Source Mixing and Conflation

What to watch: The model merges information from multiple sources into a single claim and cites only one source, or attributes a synthesized conclusion to a source that only partially supports it. The output reads coherently but the attribution is misleading. Guardrail: Require one-citation-per-claim granularity. When a claim draws from multiple sources, require all supporting sources to be cited, not just one. Add a verification step that asks: 'Is every factual claim in this sentence supported by every cited source?' Flag claims where the answer is no.

06

Missing Citations for Inferred Claims

What to watch: The model makes reasonable inferences or background statements that aren't directly in any source but presents them alongside cited claims without distinguishing which is which. Readers can't tell what's grounded and what's model reasoning. Guardrail: Require explicit markers for inferred vs. sourced content. Add an instruction that unsourced statements must be prefixed with indicators like 'The model infers that...' or 'This may suggest...' Include a verification pass that flags any declarative factual statement without an adjacent citation and classifies it as either 'common knowledge' or 'requires citation.'

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to grade the Citation and Source Attribution Adherence Prompt's output before shipping. Each criterion targets a specific failure mode in RAG citation pipelines. Run these checks programmatically or via an LLM judge.

CriterionPass StandardFailure SignalTest Method

Claim-to-Citation Coverage

Every factual claim in the [OUTPUT] has at least one corresponding [SOURCE_ID] citation

A declarative sentence containing a specific fact, number, or date has no adjacent citation marker

Parse [OUTPUT] into sentences; for each sentence with a named entity or numeric value, assert presence of a citation marker within the same sentence or the preceding one

Citation Format Adherence

All citations match the required format pattern specified in [CITATION_FORMAT] without deviation

A citation appears as plain text, a malformed bracket, or an invented format not matching the schema

Regex match all citation instances against the [CITATION_FORMAT] pattern; flag any non-matching substrings

Hallucinated Source Detection

Every [SOURCE_ID] cited in the [OUTPUT] exists in the provided [SOURCE_MATERIALS] list

A citation references a source ID not present in the input context

Extract all unique [SOURCE_ID] values from citations; compute set difference against known source IDs from [SOURCE_MATERIALS]

Quotation Length Compliance

No direct quotation exceeds the [MAX_QUOTE_LENGTH] limit defined in the prompt constraints

A quoted string longer than the allowed word or character limit appears in the output

Use regex to extract all quoted strings; measure length; flag any exceeding [MAX_QUOTE_LENGTH]

Attribution Accuracy

The content surrounding a citation accurately reflects the information in the cited source passage

A citation is placed next to a claim that contradicts or is absent from the referenced source text

For a sample of citations, retrieve the corresponding source passage; use an NLI model or LLM judge to check entailment between the claim and the passage

Abstention Correctness

When [SOURCE_MATERIALS] contains no relevant information, the output abstains rather than fabricating an answer

An answer is provided with low-confidence language or invented citations when no supporting source exists

Provide a test case with empty or irrelevant [SOURCE_MATERIALS]; assert the output contains the abstention phrase specified in [ABSTENTION_PHRASE]

Citation Placement Precision

Citations are placed directly after the specific claim they support, not aggregated at the end of a paragraph

Multiple citations are clustered at the end of a long paragraph with no clear claim-to-source mapping

Parse the output; for each paragraph with multiple claims, verify that each claim has an inline citation before the next claim begins

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a small set of 5–10 source–claim pairs. Use a frontier model with default temperature. Skip the structured output schema initially—ask for a plain-text report with sections for missing citations, hallucinated sources, and format violations. Focus on getting the reasoning right before locking down the output shape.

Watch for

  • The model flagging legitimate paraphrases as missing citations
  • Overly strict quote-boundary checks that reject acceptable summaries
  • No distinction between "source exists but wasn't cited" and "claim has no supporting source at all"
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.