Inferensys

Prompt

Cross-Document Citation Repair Prompt Template

A practical prompt playbook for using Cross-Document Citation Repair Prompt Template in production AI workflows.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the job-to-be-done, ideal user, required context, and boundaries for the Cross-Document Citation Repair prompt.

This prompt is a post-generation repair tool for multi-document RAG systems where citations point to the correct chunk of text but the wrong parent document. It is designed for the compliance audit and remediation loop, not for generating initial answers. The ideal user is an engineering lead or MLOps engineer who has already observed document-level attribution errors in production logs or eval results and needs a structured, automatable correction step before the answer is surfaced to users or written to an audit log.

Use this prompt when your retrieval corpus contains documents with overlapping or semantically similar content, causing the model to confuse which document a chunk belongs to. It is also appropriate when chunk-level citation IDs are ambiguous across documents, or when a downstream compliance requirement mandates document-level attribution accuracy. The prompt requires three inputs: the original answer with inline citations, the cited source chunks with their chunk IDs, and the full document corpus metadata including document IDs, titles, and any other distinguishing fields. It outputs a structured correction log that remaps each citation to the correct document and flags any citations that could not be resolved.

Do not use this prompt to fix chunk-level misalignment within a single document, to generate initial answers from retrieved context, or to repair hallucinated citations where the cited chunk itself does not exist. It assumes the chunk-level evidence is correct and only the document assignment is wrong. For those other failure modes, use the RAG Citation Answer Repair, Citation-to-Evidence Alignment, or Hallucinated Citation Removal prompts instead. Before deploying this prompt in production, pair it with a validation step that checks the correction log against the corpus metadata to prevent the repair loop from introducing new errors.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Cross-Document Citation Repair Prompt Template works and where it introduces risk. Use these cards to decide whether this prompt is the right tool for your current repair job.

01

Good Fit: Multi-Document RAG Pipelines

Use when: your retrieval system pulls chunks from 10+ documents and the model cites Document A when the evidence came from Document B. Guardrail: provide the prompt with a complete source manifest (document ID, title, chunk text) so it can remap citations to the correct source.

02

Bad Fit: Single-Document Citation Repair

Avoid when: all citations reference the same document and the problem is chunk-level misalignment, not document-level misattribution. Guardrail: route single-document issues to the Citation-to-Evidence Alignment Prompt Template instead. Cross-document repair adds unnecessary complexity when only one source exists.

03

Required Inputs

What you must provide: the original model output with broken citations, a source manifest mapping every document ID to its title and content, and the retrieval metadata showing which chunks came from which document. Guardrail: missing source manifests force the prompt to guess, which produces hallucinated remappings. Validate manifest completeness before invoking repair.

04

Operational Risk: Silent Misattribution

What to watch: the prompt remaps a citation to the wrong document without flagging low confidence. Users see a corrected citation and trust it. Guardrail: require the prompt to output a correction log with confidence scores per remapping. Gate outputs below your confidence threshold for human review before they reach users.

05

Operational Risk: Corpus Drift

What to watch: the source manifest used during repair is stale. Documents have been updated, removed, or re-indexed since the original generation. Guardrail: version your source manifests alongside retrieval indices. Validate that the manifest timestamp matches the retrieval window before running repair. Reject repairs when the corpus has changed.

06

Scale Limit: Large Corpora

What to watch: with 100+ documents, the prompt context window fills with the source manifest, leaving insufficient room for the actual repair work. Guardrail: pre-filter the manifest to only documents that appear in the retrieval metadata or are plausible misattribution targets. Use a two-pass approach: first identify candidate documents, then repair with a focused manifest.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A copy-ready prompt template for repairing cross-document citation errors in multi-document RAG outputs.

This prompt template is designed to be the core repair step in a post-generation validation pipeline. It receives a model's original answer, the set of source documents it was supposed to use, and a list of detected citation errors. Its job is to produce a corrected answer with citations remapped to the correct source documents, along with a structured correction log. The template uses square-bracket placeholders for all dynamic inputs—replace each one with actual values from your application context before sending the prompt to the model.

text
You are a citation repair specialist. Your task is to correct cross-document citation errors in a model-generated answer.

## INPUT

### Original Answer with Broken Citations
[ORIGINAL_ANSWER]

### Source Document Corpus
[DOCUMENT_CORPUS]

### Detected Citation Errors
[ERROR_LIST]

## TASK

1. For each citation error in the error list, identify the claim that was incorrectly attributed.
2. Search the source document corpus to find which document actually contains the supporting evidence for that claim.
3. Remap the citation to the correct document ID.
4. If no document in the corpus supports the claim, replace the citation with [UNSUPPORTED] and flag it in the correction log.
5. Preserve all other text, formatting, and correct citations exactly as they appear in the original answer.

## OUTPUT_SCHEMA

Return a JSON object with this structure:
{
  "repaired_answer": "The full answer text with corrected citations",
  "correction_log": [
    {
      "original_citation": "string",
      "original_document_id": "string",
      "corrected_document_id": "string or null if unsupported",
      "claim_text": "string",
      "correction_type": "remap|removal|unresolvable",
      "confidence": "high|medium|low"
    }
  ],
  "summary": {
    "total_citations": "number",
    "errors_corrected": "number",
    "unsupported_claims_flagged": "number",
    "unresolvable_errors": "number"
  }
}

## CONSTRAINTS

- Do not alter the original answer text except to change citation markers.
- Only use document IDs that exist in the provided source document corpus.
- If a claim appears in multiple documents, cite the most directly relevant one.
- Set confidence to "low" if the supporting evidence is partial or ambiguous.
- Never invent document IDs, source content, or supporting evidence.

Adaptation guidance: Replace [ORIGINAL_ANSWER] with the full text output from your RAG system, including all inline citation markers. [DOCUMENT_CORPUS] should contain every source document with its unique ID and full text—structure this as a JSON array or formatted list that the model can search against. [ERROR_LIST] should be a structured list of detected mismatches, typically produced by an upstream validation step that compares cited document IDs against the actual corpus. For high-stakes domains, add a [RISK_LEVEL] placeholder that gates whether corrections are applied automatically or routed to human review. The output schema is designed to be machine-readable so your application can parse the correction log and apply only high-confidence remappings automatically while escalating low-confidence or unresolvable cases.

IMPLEMENTATION TABLE

Prompt Variables

Inputs the Cross-Document Citation Repair prompt needs to work reliably. Validate each before sending to prevent cascading attribution errors in multi-document RAG systems.

PlaceholderPurposeExampleValidation Notes

[ORIGINAL_OUTPUT]

The model-generated text containing broken cross-document citations that need repair

According to [Doc3], the quarterly revenue increased 12%...

Required. Must be non-empty string. Check for presence of citation markers or reference IDs before invoking repair. Null or empty input should abort with no-op.

[SOURCE_DOCUMENTS]

The complete corpus of source documents with their canonical IDs and full text, used to remap citations to correct documents

{"documents": [{"id": "doc-001", "title": "Q4 Earnings Report", "content": "..."}, {"id": "doc-002", "title": "Market Analysis", "content": "..."}]}

Required. Must be valid JSON array with at least 2 documents. Each document requires id, title, and content fields. Validate schema before sending. Missing or single-document input should skip repair.

[CITATION_PATTERN]

Regex or pattern definition that identifies citation markers in the original output, used to extract and remap references

"\[Doc\d+\]" or "\([A-Za-z]+ et al\.\)"

Required. Must be a valid regex string. Test against [ORIGINAL_OUTPUT] to confirm matches exist. If no matches found, repair is unnecessary and prompt should not be invoked.

[OUTPUT_SCHEMA]

Expected JSON schema for the repair output, defining the structure of corrected text and the correction log

{"corrected_text": "string", "corrections": [{"original_citation": "string", "corrected_document_id": "string", "confidence": "float", "evidence_snippet": "string"}]}

Required. Must be valid JSON Schema. Include required fields: corrected_text and corrections array. Each correction entry requires original_citation, corrected_document_id, confidence, and evidence_snippet. Validate schema parse before sending.

[CONFIDENCE_THRESHOLD]

Minimum confidence score for accepting a citation remapping; citations below this threshold are flagged for human review instead of auto-corrected

0.75

Required. Must be float between 0.0 and 1.0. Default 0.75. Lower values risk incorrect remapping; higher values increase human-review volume. Validate range before sending.

[MAX_CITATIONS]

Upper bound on the number of citation markers to process in a single repair call, preventing unbounded token consumption

50

Required. Must be positive integer. Count citations in [ORIGINAL_OUTPUT] before invoking. If count exceeds [MAX_CITATIONS], split into batches or escalate. Prevents timeout and cost overruns on heavily cited documents.

[ABSTENTION_MARKER]

String inserted when a citation cannot be confidently remapped to any source document, signaling the gap to downstream systems

"[CITATION UNVERIFIED]"

Required. Must be a non-empty string distinct from valid citation patterns. Should not match [CITATION_PATTERN] to avoid recursive repair loops. Validate that marker does not appear in [SOURCE_DOCUMENTS] content.

[HUMAN_REVIEW_FLAG]

Boolean controlling whether low-confidence corrections are auto-applied or routed to a review queue; overrides [CONFIDENCE_THRESHOLD] behavior when true

Required. Must be boolean. When true, corrections below [CONFIDENCE_THRESHOLD] are held for review. When false, best-guess remapping is applied. Set true for compliance-sensitive or high-trust systems.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Cross-Document Citation Repair prompt into a production RAG pipeline with validation, retries, and audit logging.

The Cross-Document Citation Repair prompt operates as a post-retrieval correction layer, sitting between the initial answer generation step and the final user-facing output. In a typical RAG pipeline, a model generates an answer with inline citations referencing source chunks, but when the retrieval corpus spans multiple documents, the model can misattribute a citation to the wrong document—citing doc_7 when the evidence actually came from doc_3. This prompt accepts the generated answer, the full set of retrieved source chunks with their document-level metadata, and a mapping of citation markers to their claimed source IDs. It then produces a corrected answer with remapped citations and a structured correction log that records every attribution change, the evidence that justified the change, and a confidence score per correction.

To integrate this into an application, wrap the prompt in a repair loop that triggers after the primary answer generation step. The harness should: (1) extract all citation markers from the generated answer using a regex or parser that matches your citation format; (2) retrieve the full text of each cited source chunk from your vector store or document store, including the parent document identifier; (3) call the repair prompt with the answer, the source chunk map, and a [CITATION_FORMAT] specification; (4) parse the structured output—typically a JSON object containing repaired_answer, correction_log, and unresolvable_citations; (5) validate that every citation in the repaired answer maps to a real source chunk in the provided corpus; and (6) if unresolvable_citations is non-empty, either escalate for human review or apply a fallback strategy such as removing the unresolvable citation and inserting an abstention marker. For high-throughput systems, batch multiple answers into a single repair call where context windows permit, but keep each answer's source chunk set isolated to avoid cross-contamination.

Model choice matters here. This task requires strong instruction-following and structured output reliability, not creative generation. Use a model with native JSON mode or structured output support—GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro with response schema constraints. Set temperature=0 to minimize variance in citation remapping. Implement a retry policy with up to 3 attempts if the output fails JSON schema validation or if the correction log references source IDs not present in the input corpus. Log every repair call with: the original answer, the correction log, the validation result, and whether the output was served to the user or escalated. This audit trail is essential for debugging attribution drift over time and for demonstrating compliance in regulated domains. Avoid using this prompt on streaming outputs without first buffering the complete answer—partial citation repair on incomplete text will produce incorrect remappings and false-positive unresolvable flags.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the structure, types, and validation rules for the corrected output produced by the Cross-Document Citation Repair Prompt. Use this contract to build a post-processing validator before the output reaches downstream systems or users.

Field or ElementType or FormatRequiredValidation Rule

corrected_output

string

Must be valid markdown or plain text. Must contain all original claims with corrected citation markers. Parse check: no unclosed brackets or orphaned reference IDs.

correction_log

array of objects

Each entry must have fields: original_citation, corrected_citation, source_document_id, correction_reason, confidence. Array must not be empty if any citation was remapped.

correction_log[].original_citation

string

Must match a citation marker present in the input text. Regex check against input citation pattern.

correction_log[].corrected_citation

string

Must reference a valid document_id from the provided [SOURCE_CORPUS]. Must differ from original_citation. Null allowed only if citation was removed as hallucinated.

correction_log[].source_document_id

string

Must exist in the [SOURCE_CORPUS] document list. Case-sensitive match required.

correction_log[].correction_reason

enum

Must be one of: wrong_document, hallucinated_source, ambiguous_match, merged_reference, split_reference. No free-text values allowed.

correction_log[].confidence

float

Range 0.0 to 1.0. Values below [CONFIDENCE_THRESHOLD] must trigger human review flag. Parse check: valid float, no NaN or infinity.

uncorrectable_citations

array of strings

Each entry must be a citation marker from input that could not be resolved. If empty, field must be present as empty array. Null not allowed.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when repairing cross-document citations in production and how to guard against it.

01

Source Document Confusion

What to watch: The model attributes a claim to Document A when the evidence clearly originates from Document B, especially when documents share similar topics or authors. This is the core failure mode for cross-document repair. Guardrail: Require the prompt to output a correction log mapping each citation to its verified source document ID with a confidence score. Validate that every corrected citation's quoted text appears verbatim in the claimed source document before accepting the repair.

02

Correction Cascade Collapse

What to watch: Fixing one misattributed citation causes the model to incorrectly remap adjacent citations, creating a cascade of new errors. This happens when the model over-generalizes from a single correction. Guardrail: Instruct the model to repair citations independently and justify each remapping with explicit evidence from the target document. Implement a post-repair diff that flags any citation change not accompanied by a source-grounded explanation.

03

Phantom Document References

What to watch: The repair prompt invents a new document ID or source title that doesn't exist in the corpus to resolve an ambiguous citation, effectively replacing one hallucination with another. Guardrail: Constrain the repair prompt to only use document IDs from a provided closed list. Add a validator that rejects any output containing a document identifier not present in the input corpus manifest.

04

Silent Attribution Dropping

What to watch: When the model cannot confidently remap a broken citation, it removes the citation marker entirely rather than flagging it as unresolved, leaving claims unsubstantiated. Guardrail: Require the prompt to preserve all original claims and use an explicit [UNRESOLVED] marker for citations that cannot be repaired. Audit the output to ensure the number of claims with attribution equals or exceeds the input count.

05

Cross-Document Context Contamination

What to watch: The model blends content from multiple documents when repairing a single citation, creating a hybrid attribution that doesn't faithfully represent any single source. Guardrail: Instruct the prompt to verify that each repaired citation's supporting passage comes from exactly one document. Add an eval step that checks for multi-document splice patterns in quoted evidence.

06

Correction Log Drift from Actual Changes

What to watch: The model outputs a correction log that describes changes inaccurately—claiming it fixed a citation when it actually changed the wrong one, or reporting a successful repair when the citation remains broken. Guardrail: Implement a deterministic reconciliation step that compares the before and after citation maps and verifies each log entry against the actual diff. Flag any log entry that doesn't match the computed change.

IMPLEMENTATION TABLE

Evaluation Rubric

Run these checks on a golden dataset of 20-50 known cross-document citation errors. Each row targets a distinct failure mode that must pass before shipping the repair prompt.

CriterionPass StandardFailure SignalTest Method

Document-level attribution accuracy

95% of repaired citations point to the correct source document ID

Repaired document ID does not match the golden expected document ID for that claim

Exact match comparison against golden dataset expected_doc_id per citation

Correction log completeness

Every citation change produces exactly one correction log entry with before/after document IDs

Missing log entry for a changed citation, or log entry present for an unchanged citation

Count log entries and compare against diff of input vs. output citation-to-document mappings

Unchanged citation preservation

0% of correctly attributed citations in the input are modified in the output

A citation that was already correct in the input has a different document ID in the output

Identify citations where input doc_id equals golden doc_id and verify output doc_id is unchanged

Correction log schema validity

100% of correction log entries conform to the required schema with all required fields present

Log entry missing required field such as claim_index, original_doc_id, corrected_doc_id, or confidence

JSON Schema validation of each correction log entry against the defined output contract

Confidence score calibration

Mean confidence score for correct repairs is at least 0.8; mean for incorrect repairs is below 0.6

High confidence assigned to an incorrect repair or low confidence assigned to a correct repair

Compute mean confidence for repairs where output doc_id matches vs. mismatches golden doc_id

Cross-document claim boundary detection

100% of claims spanning multiple documents are split and attributed to the correct individual documents

A multi-document claim is attributed to a single document or split claims are assigned to wrong documents

Check golden dataset multi-document claim markers against output claim segmentation and per-segment doc_id

Abstention on unresolvable citations

Citations with no matching source in the corpus receive an abstention marker, not a guessed document ID

An unresolvable citation is assigned a document ID instead of the abstention marker

Filter golden dataset entries marked unresolvable and verify output contains abstention marker for those citations

Output text integrity

Non-citation text in the output is byte-identical to the input aside from citation marker changes

Words, punctuation, or whitespace outside citation spans differ between input and output

Strip citation markers from both input and output, then compare normalized text for exact match

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a small test corpus of 5-10 documents. Skip formal schema validation on the correction log output. Focus on getting the remapping logic right before adding infrastructure.

code
You are a citation repair specialist. Given a model response that cites documents from a multi-document corpus, identify every citation that references the wrong document. For each misattributed citation, remap it to the correct source document using the provided document list. Output a correction log.

### INPUT
- Model response with citations: [RESPONSE_WITH_CITATIONS]
- Document list with IDs and summaries: [DOCUMENT_LIST]

### OUTPUT
A correction log with:
- original_citation: the citation as it appears
- wrong_document_id: the document currently cited
- correct_document_id: the document that should be cited
- evidence: the sentence or passage from the correct document that supports the claim
- confidence: HIGH | MEDIUM | LOW

Watch for

  • Missing evidence field when the correct document is ambiguous
  • Overly broad document summaries that cause false remappings
  • No handling of citations that reference documents not in the provided list
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.