This prompt is for RAG system operators and AI engineers who have just compressed or truncated retrieved context and need to verify that every citation marker in the compressed output still maps to a retrievable source passage. The job-to-be-done is preventing orphaned citations—references that point to evidence that was dropped during compression—from reaching end users. If your system generates answers with inline citations (e.g., [1], [doc-4]) and you run a compression step before answer generation, you need this verification gate between compression and the final model call.
Prompt
Citation Integrity Verification Prompt After Truncation

When to Use This Prompt
Define the job, ideal user, and constraints for verifying citation integrity after context compression.
Use this prompt when your compression pipeline is lossy—when it summarizes, prunes, or reorders passages and you cannot guarantee that all citation targets survive. It is especially critical in regulated or high-trust domains (legal, clinical, financial) where a citation to missing evidence creates audit risk. Do not use this prompt if your compression is purely extractive and preserves every source passage intact with its original identifier; in that case, citation integrity is structural, not semantic. Also skip this prompt if your downstream answer generator does not produce citations at all—there is nothing to verify.
The ideal user is an engineer building a production RAG pipeline who needs an automated verification step that runs after compression and before answer generation. You should wire this prompt into a pre-inference validation harness: if the verification report flags orphaned citations, either repair the compressed context by re-inserting the missing passages, drop the orphaned citation markers, or escalate for human review depending on your risk tolerance. For high-stakes workflows, always require human approval when orphaned citations are detected rather than silently dropping them.
Use Case Fit
Where the Citation Integrity Verification Prompt fits into a production RAG pipeline and where it creates risk. This prompt is a post-compression safety net, not a replacement for upstream evidence ranking.
Good Fit: Post-Compression QA Gate
Use when: you have just run a compression or truncation step on retrieved context and need to verify that every citation marker in the compressed output still maps to a retrievable source passage. Guardrail: Run this prompt as a blocking gate before the compressed context is passed to the answer-generation model. If orphaned citations are detected, route to a repair or re-expansion step.
Bad Fit: Replacing Upstream Evidence Ranking
Avoid when: you are tempted to use this prompt to decide which sources to keep. This prompt verifies citation integrity after compression; it does not rank or select evidence. Guardrail: Use a dedicated Evidence Ranking Prompt upstream to select the strongest passages before compression. This prompt only validates the output of that pipeline.
Required Inputs
What you need: the original pre-compression context with citation markers, the compressed context with citation markers, and a mapping of citation IDs to retrievable source passages. Guardrail: If any of these three inputs are missing or incomplete, the verification report will be unreliable. Validate input completeness in your prompt assembly harness before calling this prompt.
Operational Risk: Silent Hallucination Propagation
Risk: a compressed context with orphaned citations that passes unnoticed into the answer-generation step will produce answers that appear cited but are unsupported. Guardrail: Make this verification prompt a required step in your RAG pipeline. Log every verification report and trigger an alert if orphaned citations exceed a threshold. Never skip this step in regulated or high-trust domains.
Latency and Cost Trade-Off
Risk: adding a verification step increases end-to-end latency and token cost, especially for long contexts with many citations. Guardrail: Use this prompt selectively for high-stakes queries, regulated outputs, or when compression aggressiveness is high. For low-risk, high-volume traffic, consider sampling-based verification or a lighter-weight regex-based citation check before falling back to this prompt.
Human Review Escalation Path
Risk: the verification prompt itself may produce false positives or miss subtle citation drift where a citation maps to the wrong passage. Guardrail: For compliance-critical outputs, route verification reports with unresolved conflicts or high orphan counts to a human review queue. Do not auto-resolve by dropping citations without human approval when the stakes are high.
Copy-Ready Prompt Template
A reusable prompt template for verifying citation integrity after context compression, ensuring every citation marker maps to a retrievable source passage.
This prompt template is designed to be dropped into a RAG pipeline immediately after a context compression or truncation step. Its job is to verify that every citation marker present in the compressed context still references a passage that exists in the original source material and that no orphaned citations—markers pointing to dropped or hallucinated sources—remain. The template uses square-bracket placeholders so you can substitute your own compressed context, original source passages, citation format rules, and risk thresholds without rewriting the core verification logic.
textYou are a citation integrity verifier for a RAG system. Your task is to confirm that every citation marker in the [COMPRESSED_CONTEXT] maps to a retrievable passage in the [ORIGINAL_SOURCES] and that no orphaned citations exist. ## INPUTS - Compressed context: [COMPRESSED_CONTEXT] - Original source passages (with source IDs): [ORIGINAL_SOURCES] - Citation format: [CITATION_FORMAT] (e.g., "[1]", "(Author, Year)", "§4.2") - Risk level: [RISK_LEVEL] (low, medium, high, critical) ## OUTPUT SCHEMA Return a JSON object with the following structure: { "verification_report": { "total_citations_found": <integer>, "verified_citations": <integer>, "orphaned_citations": <integer>, "citation_details": [ { "citation_marker": "<string>", "status": "verified | orphaned | ambiguous", "mapped_source_id": "<string or null>", "mapped_passage_excerpt": "<string or null>", "confidence": "high | medium | low", "issue_description": "<string or null>" } ], "overall_pass": <boolean>, "critical_failures": ["<string>"] } } ## CONSTRAINTS 1. Do not infer or fabricate source passages. If a citation marker cannot be matched to an exact passage in [ORIGINAL_SOURCES], mark it as orphaned. 2. For ambiguous matches where a citation could refer to multiple passages, mark status as "ambiguous" and list all candidate source IDs in issue_description. 3. If [RISK_LEVEL] is "high" or "critical", flag any orphaned or ambiguous citation as a critical_failure and set overall_pass to false. 4. If [RISK_LEVEL] is "low", orphaned citations with low confidence may still pass if they represent less than 5% of total citations. 5. Preserve the exact citation marker string as it appears in [COMPRESSED_CONTEXT] in the citation_marker field. 6. If [COMPRESSED_CONTEXT] contains no citation markers at all, return total_citations_found: 0, overall_pass: true, and note this in critical_failures only if citations were expected per [CITATION_FORMAT]. ## VERIFICATION STEPS 1. Extract every citation marker from [COMPRESSED_CONTEXT] using the [CITATION_FORMAT] pattern. 2. For each marker, search [ORIGINAL_SOURCES] for the corresponding source ID and passage. 3. Confirm that the cited claim or fact in the compressed context is supported by the mapped passage. 4. If a marker references a source ID not present in [ORIGINAL_SOURCES], mark as orphaned. 5. If a marker references a valid source ID but the passage content does not support the surrounding claim, mark as ambiguous with an explanation. 6. Compile the verification report and set overall_pass based on [RISK_LEVEL] thresholds.
To adapt this template, replace each square-bracket placeholder with your pipeline's actual values. For [ORIGINAL_SOURCES], pass the full source passages with their IDs as they existed before compression—not the compressed versions. For [CITATION_FORMAT], provide a regex-ready pattern or a natural-language description of your citation style. The [RISK_LEVEL] placeholder controls the strictness of the pass/fail decision; wire this to your application's risk configuration so that regulated or customer-facing workflows fail closed on any orphaned citation. After the verification report is returned, your application layer should gate the downstream use of the compressed context: if overall_pass is false, either repair the context, re-retrieve dropped sources, or escalate for human review before the compressed context reaches the answer-generation step.
Prompt Variables
Required inputs for the Citation Integrity Verification Prompt. Each placeholder must be populated before the prompt is assembled and sent. Missing or malformed variables will cause verification failures or silent false positives.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[COMPRESSED_CONTEXT] | The truncated or compressed context block containing inline citation markers that must be verified | According to [src_7], the API rate limit is 100 req/min. See also [src_12] for quota details. | Must contain at least one citation marker in [src_id] format. Reject if empty or if markers use an unrecognized format. |
[CITATION_FORMAT] | The regex or pattern definition for citation markers used in the compressed context | [src_\d+] or [doc_\w+] | Must be a valid regex or explicit pattern string. Validate that the pattern matches actual markers found in [COMPRESSED_CONTEXT] before inference. |
[SOURCE_INDEX] | A mapping of citation IDs to retrievable source passages, provided as a structured object or list | {"src_7": "API rate limits are enforced at 100 requests per minute per API key.", "src_12": "Quota details are available in the developer console under Usage."} | Every citation ID extracted from [COMPRESSED_CONTEXT] must have a corresponding entry. Missing entries will produce orphaned citation errors. Validate key coverage before inference. |
[OUTPUT_SCHEMA] | The expected JSON schema for the verification report | {"verified": [], "orphaned": [], "unverifiable": [], "summary": ""} | Must be a valid JSON Schema or example structure. Reject if schema is missing required fields for verified, orphaned, and unverifiable citation lists. |
[STRICTNESS_LEVEL] | Controls whether partial matches, paraphrased support, or semantic equivalence counts as verification | exact_match | semantic_equivalence | lenient | Must be one of the enumerated values. Default to exact_match for regulated domains. Lenient mode requires additional human review gating. |
[MAX_ORPHANED_THRESHOLD] | The maximum number of orphaned citations allowed before the verification is considered failed and triggers a retry or human review | 0 for compliance use cases; 2 for draft or internal workflows | Must be a non-negative integer. A value of 0 enforces strict citation integrity. Values above 0 require a downstream escalation path for orphaned citations. |
[HUMAN_REVIEW_REQUIRED] | Boolean flag indicating whether the verification report must be routed for human approval before the compressed context is used downstream | true for regulated, legal, or clinical domains; false for internal tooling | Must be true or false. When true, the system must not auto-proceed on orphaned or unverifiable citations regardless of [MAX_ORPHANED_THRESHOLD]. |
Implementation Harness Notes
How to wire the citation integrity verification prompt into a RAG pipeline with validation, retries, and human review gates.
The citation integrity verification prompt is designed to run as a post-truncation validation step in a RAG pipeline, not as a standalone tool. After your context compression or truncation module produces a condensed context with embedded citation markers, this prompt acts as a quality gate before the final generation step. The typical integration point is between the context assembly layer and the answer generation model: the compressed context and its source mapping are passed to this verification prompt, and only contexts that pass verification proceed to the answer generator. This prevents orphaned citations—markers that reference source passages no longer present in the compressed context—from reaching the user as broken or unverifiable claims.
To wire this into an application, build a verification function that accepts two inputs: the compressed context string containing citation markers (e.g., [1], [2]) and a source mapping object that links each marker to its original retrievable passage. The function should call the verification prompt with both inputs and parse the structured output—a JSON object containing a verification_status field (pass or fail), a citation_map array listing each marker and whether it maps to a present passage, and an orphaned_citations array listing any markers without matching source content. Implement a retry loop: if verification fails due to orphaned citations, route the failure back to your truncation module for correction before re-verification. Set a maximum of three retry cycles before escalating to a human reviewer or logging the failure for offline analysis. For model choice, use a model with strong instruction-following and structured output capabilities—GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro are suitable. Avoid smaller or older models that may hallucinate verification results, defeating the purpose of the check.
Validation should include both structural and semantic checks. Structurally, confirm that the verification output is valid JSON matching your expected schema and that every citation marker from the compressed context appears in the citation_map. Semantically, implement a spot-checking mechanism: randomly sample 10-20% of verified citation-to-passage mappings and run a secondary factuality check comparing the cited passage against the compressed context's claim. This catches cases where the verification model incorrectly passes a citation that references distorted or summarized content rather than the original passage. Log every verification result with the compressed context, source mapping, verification output, and any spot-check discrepancies. For high-stakes domains such as legal, medical, or financial applications, add a human review gate that requires manual approval for any verification run where orphaned citations were detected and repaired, or where spot-checking reveals semantic drift between the compressed context and source passages. Do not allow auto-repaired contexts to reach end users in regulated workflows without human sign-off.
Common failure modes in the harness include: the verification model hallucinating citation markers that don't exist in the compressed context, producing malformed JSON under high token pressure, or passing citations where the compressed context paraphrased the source beyond recognition. Mitigate these by setting a low temperature (0.0-0.1) for deterministic outputs, using structured output APIs where available, and implementing a schema validator that rejects any verification response missing required fields. If the verification model consistently fails on long compressed contexts, split the context into chunks of 3-5 citation markers each and run verification in parallel, then merge results. Monitor verification latency and cost—this prompt adds an extra inference call to your pipeline, so track its token usage and set alerts if verification costs exceed 20% of your total RAG pipeline spend. The verification step should be fast and cheap relative to the generation step it protects.
Common Failure Modes
What breaks first when verifying citation integrity after context truncation, and how to guard against it.
Orphaned Citation Markers
What to watch: The compressed context contains citation markers (e.g., [src-4]) that reference source passages dropped during truncation. The verification prompt may fail to flag these if it only checks marker format, not source existence. Guardrail: Require the verification prompt to cross-reference every citation marker against the actual retained source list, not just the marker pattern. Output a specific 'orphaned_citations' array in the verification report.
Hallucinated Source Mappings
What to watch: The verification prompt itself hallucinates that a citation maps to a source passage when the passage content doesn't actually support the cited claim. The model confirms integrity without checking semantic alignment. Guardrail: Add a 'claim-to-snippet alignment' check step that requires the verifier to extract the cited claim and the source snippet, then confirm they match. Flag any citation where the source snippet doesn't contain the claimed fact.
Truncation-Induced Citation Drift
What to watch: The compression step rewrites or summarizes source passages, and citation markers now point to compressed text that no longer contains the exact evidence the original citation referenced. The verifier sees a valid marker-to-passage link but misses that the passage content changed. Guardrail: Require the verification prompt to compare the compressed passage against the original source passage for each citation. Flag any citation where the compressed version dropped or altered the cited evidence.
Implicit Citation Blind Spots
What to watch: The compressed context introduces claims that appear to be supported by surrounding citations but aren't explicitly cited. The verifier only checks explicit markers and misses these 'borrowed authority' statements. Guardrail: Add a 'claim extraction' pre-check that lists every factual claim in the compressed context, then verifies each claim has at least one explicit citation marker. Flag uncited claims as 'unsupported_statements' in the report.
Verification Prompt Self-Confidence Overestimation
What to watch: The verification prompt reports high confidence in citation integrity even when source passages are ambiguous, contradictory, or only partially supportive. The model defaults to confirming integrity rather than flagging uncertainty. Guardrail: Require the verifier to output a confidence score per citation with explicit reasoning. Add a calibration check: if the verifier can't quote the exact supporting text from the source, it must downgrade confidence to 'uncertain' and flag for human review.
Source Identifier Collision After Deduplication
What to watch: The deduplication or compression step merges overlapping sources and reassigns citation markers. The verification prompt uses the new marker scheme but some citations still reference old markers from before deduplication, creating broken links the verifier doesn't catch. Guardrail: Include a 'marker migration map' in the verification input that documents how old markers map to new ones. Require the verifier to confirm every citation marker in the final output resolves through this map to an existing retained source.
Evaluation Rubric
Use this rubric to test the citation integrity verification output before shipping. Each criterion targets a specific failure mode that breaks downstream trust in compressed RAG context.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Orphaned Citation Detection | Every citation marker in the compressed context appears in the verification report with a status of mapped or unmapped | Report omits a citation marker present in the compressed context | Parse all citation markers from compressed context; confirm each appears in the report's citation list |
Source Passage Mapping | Every mapped citation resolves to a retrievable source passage with a valid source ID and passage offset | Mapped citation points to a source ID not present in the original retrieval set or an offset outside the passage bounds | Cross-reference each mapped citation's source ID and offset against the original retrieval manifest |
Unmapped Citation Flagging | Every citation that cannot be mapped to a source passage is explicitly flagged as unmapped with a reason code | Unmapped citation appears without a reason code or is silently dropped from the report | Count unmapped citations in report; verify each has a non-empty reason field from the allowed enum |
False Positive Mapping | No citation is mapped to a passage that does not contain the cited claim | Report maps a citation to a passage where the claim text is absent or semantically contradicted | Sample 20% of mapped citation-passage pairs; perform string containment and semantic entailment check |
Report Schema Compliance | Output matches the expected JSON schema with all required fields present and correctly typed | Missing required field, wrong type, or extra unmapped citations in a separate unstructured block | Validate output against the [OUTPUT_SCHEMA] using a JSON schema validator; reject on any violation |
Source Provenance Preservation | Every mapped passage retains its original source ID, title, and retrieval score from the pre-truncation context | Source metadata is stripped, replaced with generated text, or provenance chain is broken | Compare source metadata in report against the original retrieval results for all mapped passages |
Truncation Boundary Handling | Citations near truncation cut points are correctly classified as mapped or unmapped based on whether their source passage survived truncation | Citation at a truncation boundary is mapped to a passage that was dropped during compression | Inject test cases with citations at known truncation boundaries; verify classification matches ground truth |
Human Review Escalation | Report includes a review_required boolean set to true when any citation is unmapped or confidence is below threshold | Unmapped citations present but review_required is false or field is absent | Assert review_required equals true when unmapped_count is greater than 0 or min_confidence is below [CONFIDENCE_THRESHOLD] |
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 single source document. Use manual spot checks instead of automated validation. Run on 10-20 compressed passages and visually inspect whether citation markers map to retrievable source text.
Simplify the output schema to a flat list of citation IDs and a pass/fail flag. Drop the detailed mismatch report and confidence scores until you confirm the prompt direction works.
Prompt modification
Replace the structured output schema with a simpler instruction:
codeFor each citation marker in [COMPRESSED_CONTEXT], state whether it maps to a retrievable passage in [ORIGINAL_SOURCE]. Return a JSON array of {citation_id, status: "valid"|"orphaned"}.
Watch for
- The model marking citations as valid without actually checking the source text
- Hallucinated citation IDs that never existed in the compressed context
- Overly permissive matching where the model accepts vague topical overlap as a valid citation

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