This prompt is designed for a specific and critical job-to-be-done: acting as a safety gate in a Retrieval-Augmented Generation (RAG) pipeline. Its ideal user is a knowledge system engineer or AI product developer who has already retrieved multiple context chunks from a vector database, search index, or document store. The core task is to programmatically decide if the assembled context is internally consistent enough for a downstream LLM to synthesize into a single, coherent answer. Without this check, a model may blend conflicting facts, leading to a confident but incorrect response that erodes user trust and creates a liability. The prompt assumes you have source identifiers (e.g., URLs, document titles, chunk IDs) attached to each piece of retrieved context, which are essential for the attribution step.
Prompt
Context Contradiction Detection Prompt for Review

When to Use This Prompt
A practical guide for RAG engineers on when to deploy the Context Contradiction Detection prompt to catch factual conflicts before they reach the user.
You should use this prompt when the cost of a factual error is high and the retrieval step frequently surfaces documents from different versions, authors, or time periods. For example, a technical support copilot might retrieve a deprecated API specification alongside the latest version, or a legal research tool might find two court rulings with opposing conclusions. The prompt's structured output—a contradiction report—is designed to be machine-readable, allowing your application to automatically halt the answer generation step and route the conflict to a human review queue. Do not use this prompt for single-source verification, where the task is to check if a claim is supported by one document. It is also unsuitable for detecting stylistic disagreements or subjective opinion differences where no factual truth is at stake; using it in these scenarios will generate a high rate of false positives, flagging benign differences as critical conflicts and overwhelming your review team.
Before integrating this prompt, ensure your upstream retrieval pipeline reliably returns context chunks with stable, unique source identifiers. A common failure mode is feeding the prompt context that has already been summarized or rephrased, which can obscure the precise factual claims and lead to missed contradictions. The next step after reading this section is to examine the prompt template and its required input variables, particularly how to structure the [CONTEXT] block with clear source attribution. Avoid the temptation to use this as a general-purpose 'fact-checker' on a single document; its strength lies in comparative analysis across multiple sources, and misapplying it will lead to unreliable and noisy outputs.
Use Case Fit
Where the Context Contradiction Detection Prompt works, where it breaks, and the operational preconditions required before deploying it in a production RAG or knowledge system.
Good Fit: Multi-Source Synthesis
Use when: your RAG pipeline retrieves from multiple documents, databases, or APIs that may disagree. The prompt excels at surfacing factual conflicts between sources before they reach the user. Guardrail: Always provide source identifiers and retrieval timestamps in the context so the model can attribute contradictions precisely.
Bad Fit: Single-Source Summarization
Avoid when: the input context comes from a single authoritative document. The prompt will hallucinate phantom contradictions or over-flag stylistic differences as factual conflicts. Guardrail: Gate invocation behind a context-count check—only trigger contradiction detection when two or more distinct sources are present.
Required Inputs
What you must provide: retrieved passages with source metadata, the user query that triggered retrieval, and a contradiction taxonomy. Without source attribution, the model cannot produce actionable escalation payloads. Guardrail: Validate that every context chunk has a non-null source ID before calling the prompt.
Operational Risk: False Conflict Rate
What to watch: the prompt may flag paraphrases, temporal updates, or differing levels of detail as contradictions. This creates reviewer fatigue and erodes trust in the escalation queue. Guardrail: Calibrate with a golden dataset of known contradictions and non-contradictions. Set a precision threshold before enabling auto-escalation.
Operational Risk: Missed Implicit Contradictions
What to watch: contradictions that require domain knowledge or quantitative reasoning to detect may be missed. The prompt catches explicit conflicts but can overlook implied disagreements. Guardrail: Pair this prompt with a domain-specific fact-checking prompt for high-stakes verticals like healthcare or finance.
Latency and Cost Boundary
What to watch: contradiction detection adds a full model round-trip to your RAG pipeline. For real-time applications, this can push latency past acceptable thresholds. Guardrail: Use this prompt asynchronously or on a sampled subset of traffic. Reserve synchronous use for high-risk query categories only.
Copy-Ready Prompt Template
A production-ready prompt for detecting factual contradictions in retrieved context and escalating with structured evidence for human review.
This prompt is designed to be dropped directly into a RAG pipeline after retrieval and before answer generation. It compares multiple source passages, identifies factual conflicts, and produces a structured contradiction report that can be routed to a human review queue. The template uses square-bracket placeholders that you replace with your actual retrieved context, output schema requirements, and escalation thresholds before deployment.
textYou are a contradiction detection system operating within a RAG pipeline. Your job is to compare multiple retrieved source passages and identify factual conflicts before answer generation proceeds. ## INPUT [RETRIEVED_CONTEXT] ## TASK 1. Extract all factual claims from each source passage. A factual claim is a verifiable statement about entities, events, dates, quantities, relationships, or properties. 2. Compare claims across sources and identify contradictions. A contradiction exists when two or more sources assert mutually exclusive facts about the same entity, event, or property. 3. For each contradiction found, produce a structured entry containing: - The conflicting claims with exact source text excerpts - Source attribution for each claim (source ID, passage index) - The type of contradiction: [CONTRADICTION_TYPES] - A severity rating: [SEVERITY_SCALE] - Whether the contradiction can be resolved by preferring a more authoritative or recent source 4. Classify the overall context set as: - CONSISTENT: No factual conflicts detected - MINOR_CONFLICT: Conflicts exist but are resolvable or low-impact - MAJOR_CONFLICT: Unresolvable conflicts that would affect answer quality - UNVERIFIABLE: Insufficient evidence to determine consistency ## CONSTRAINTS - Only flag factual contradictions, not differences in opinion, emphasis, or level of detail - Do not fabricate contradictions where sources can be reasonably reconciled - If sources use different terminology for the same entity, treat them as referring to the same entity unless context clearly indicates otherwise - Mark temporal contradictions separately from static factual contradictions - If [RISK_LEVEL] is HIGH, escalate any contradiction regardless of severity ## OUTPUT FORMAT Return a JSON object matching this schema: [OUTPUT_SCHEMA] ## EXAMPLES [EXAMPLES]
Adaptation guidance: Replace [RETRIEVED_CONTEXT] with your actual retrieved passages, including source IDs and passage indices. Define [CONTRADICTION_TYPES] as a closed set matching your domain (e.g., ["temporal", "quantitative", "entity_identity", "causal", "categorical"]). Set [SEVERITY_SCALE] to match your escalation thresholds (e.g., ["low", "medium", "high", "critical"]). Provide [OUTPUT_SCHEMA] as the exact JSON schema your downstream systems expect. Include [EXAMPLES] with at least two few-shot demonstrations: one showing a clear contradiction with proper attribution, and one showing sources that appear contradictory but are actually reconcilable. Set [RISK_LEVEL] based on your application context—use HIGH for regulated domains where any contradiction must trigger human review.
Before deploying, validate that the prompt produces parseable JSON matching your schema on at least 20 test cases with known contradictions. Measure contradiction recall (did it catch all known conflicts?) and false conflict rate (did it flag non-contradictions?). If false conflict rate exceeds 10%, add more few-shot examples showing reconcilable differences. Wire the output into a human review queue that presents the contradiction summary, source excerpts, and severity classification to a reviewer who can approve, override, or request re-retrieval before answer generation proceeds.
Prompt Variables
Required inputs for the Context Contradiction Detection Prompt. Each placeholder must be populated before the prompt is assembled and sent to the model. Validation notes define what makes each input acceptable or grounds for rejection.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[RETRIEVED_CONTEXT] | The set of passages, documents, or snippets retrieved from the knowledge base that the model must analyze for contradictions. | Passage A: The patient was prescribed 50mg of atenolol daily. Passage B: The patient's current atenolol dose is 25mg twice daily. | Must contain at least two distinct source segments. Reject if empty, single-source, or all passages are identical. Check for minimum token length per passage (>= 20 tokens). |
[SOURCE_METADATA] | Identifiers, timestamps, or provenance labels for each passage in [RETRIEVED_CONTEXT] to enable source attribution in the contradiction report. | {"passage_0": {"doc_id": "note-2024-03-15", "author": "Dr. Chen"}, "passage_1": {"doc_id": "note-2024-03-22", "author": "Dr. Singh"}} | Must map 1:1 to passages in [RETRIEVED_CONTEXT]. Reject if keys are missing, duplicate, or do not correspond to a passage. Schema check: valid JSON object with string keys. |
[CLAIM_TO_VERIFY] | An optional specific claim or statement to check for contradiction against the retrieved context. When null, the prompt detects all pairwise contradictions. | The patient is currently on 50mg of atenolol. | Null allowed. When provided, must be a declarative sentence with a single verifiable proposition. Reject if multi-claim paragraph or interrogative form. Length <= 500 characters. |
[CONTRADICTION_THRESHOLD] | The minimum confidence score (0.0 to 1.0) required to flag a contradiction for escalation. Lower values increase recall; higher values reduce false positives. | 0.7 | Must be a float between 0.0 and 1.0 inclusive. Reject if non-numeric, out of range, or null. Default to 0.5 if unset. Parse check: parseFloat and range guard. |
[OUTPUT_SCHEMA] | The expected JSON schema for the contradiction report, defining fields for contradiction pairs, evidence excerpts, confidence scores, and source attribution. | {"contradictions": [{"passage_a_id": "string", "passage_b_id": "string", "conflicting_fact": "string", "confidence": "float", "excerpt_a": "string", "excerpt_b": "string"}]} | Must be a valid JSON Schema object. Reject if malformed JSON, missing required contradiction fields, or contains unsupported types. Schema validation pass required before prompt assembly. |
[MAX_CONTRADICTIONS] | The maximum number of contradiction pairs to return in a single response. Controls output size and review queue volume. | 5 | Must be a positive integer between 1 and 20. Reject if zero, negative, non-integer, or null. Default to 10 if unset. Parse check: parseInt and range guard. |
[ESCALATION_REASON_TEMPLATE] | A template string for generating the human-readable escalation reason that accompanies each flagged contradiction in the review queue. | Contradiction detected between {source_a} and {source_b} regarding {fact}. Confidence: {confidence}. | Must contain at least the tokens {source_a}, {source_b}, {fact}, and {confidence}. Reject if template tokens are missing, malformed, or the string is empty. Length <= 300 characters. |
Implementation Harness Notes
How to wire the Context Contradiction Detection Prompt into a production RAG pipeline with validation, logging, and human review routing.
The Context Contradiction Detection Prompt is designed to sit between retrieval and answer generation in a RAG pipeline. Its job is to inspect the set of retrieved documents for factual conflicts before the model synthesizes a response. In a production harness, this prompt should be called as a dedicated validation step after retrieval returns its top-k results but before those results are passed to the final generation prompt. This separation allows the contradiction detection to run with a different model, temperature, or timeout than the main generation step, and it creates a clean decision boundary: if contradictions are found, the pipeline can either halt for human review or proceed with a contradiction-aware disclaimer appended to the final answer.
The implementation should wrap the prompt call in a structured validation layer. The prompt returns a JSON object with fields like contradiction_detected, contradiction_summary, conflicting_sources, and severity. Your harness must validate this schema on every response. If the model returns malformed JSON, retry once with a stricter instruction appended to the prompt. If the retry also fails, log the raw output and escalate the entire retrieval set to a human review queue rather than proceeding with potentially flawed context. For high-stakes domains such as clinical or legal applications, consider routing any detection with severity: "high" directly to a human reviewer and blocking automated answer generation entirely. The harness should also log every contradiction detection event with the retrieval query, the document IDs, the contradiction summary, and the final routing decision for audit and eval purposes.
Model choice matters here. Contradiction detection is a reasoning task that benefits from strong instruction-following models. In testing, smaller or quantized models often produce false positives by conflating complementary information with contradiction. Start with a capable model like Claude 3.5 Sonnet or GPT-4o, then experiment with smaller models only if latency or cost demands it, and always run a calibration eval against human-annotated contradiction labels before switching. Set temperature to 0 or near-zero to maximize consistency. The prompt should be called with a timeout appropriate to your retrieval volume; if contradiction detection adds more than 500ms to your pipeline, consider batching multiple retrieval sets or using a faster model for low-priority queries. For RAG systems with very large context windows, truncate the retrieved passages to the most relevant sections before passing them to this prompt to avoid token waste and reduce false positives from out-of-context snippets.
The human review integration is the most critical part of the harness. When the prompt flags a contradiction, your system should create a review item containing the original user query, the full text of the conflicting sources, the contradiction summary generated by the model, and a direct link to the source documents if available. Do not rely on the model's contradiction summary alone; the human reviewer needs the raw evidence to make an independent judgment. Route review items to a queue that supports prioritization by severity and tracks time-to-resolution. Over time, collect reviewer feedback on whether each flagged contradiction was a true positive or false positive. This feedback loop is essential for tuning the prompt's instructions, adjusting severity thresholds, and measuring the eval metrics described in the topic overview: contradiction recall and false conflict rate. Without this closed loop, the prompt will drift in effectiveness as your document corpus and query patterns evolve.
Expected Output Contract
Defines the structured JSON payload that the contradiction detection prompt must return. Use this contract to validate outputs before routing to human review queues.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
contradiction_detected | boolean | Must be true if any contradiction pair exists; false otherwise. No null allowed. | |
contradiction_pairs | array of objects | Must be present and non-empty when contradiction_detected is true. Validate array length > 0. | |
contradiction_pairs[].claim_a | string | Exact quote from source A. Must be substring-matchable against [SOURCE_A_TEXT]. Max 500 chars. | |
contradiction_pairs[].claim_b | string | Exact quote from source B. Must be substring-matchable against [SOURCE_B_TEXT]. Max 500 chars. | |
contradiction_pairs[].source_a_id | string | Must match a source identifier provided in [SOURCE_IDS]. Validate against known ID set. | |
contradiction_pairs[].source_b_id | string | Must match a source identifier provided in [SOURCE_IDS]. Must differ from source_a_id. | |
contradiction_pairs[].contradiction_type | string (enum) | Must be one of: factual_conflict, numerical_discrepancy, temporal_inconsistency, definitional_clash, or direct_negation. Enum validation required. | |
contradiction_pairs[].explanation | string | Concise explanation of why the claims conflict. 1-3 sentences. Must reference specific contradictory elements from both claims. | |
contradiction_pairs[].severity | string (enum) | Must be one of: critical, high, medium, or low. Critical reserved for safety, legal, or irreversible-action contexts. | |
contradiction_pairs[].resolution_candidate | string or null | Suggested resolution if inferable from context; otherwise null. When non-null, must not introduce facts absent from provided sources. | |
escalation_recommended | boolean | Must be true if any contradiction_pair.severity is critical or high. False otherwise. No null allowed. | |
escalation_summary | string | Required when escalation_recommended is true. 2-4 sentence summary for human reviewer covering what conflicts, why it matters, and what action is needed. | |
confidence_score | number (0.0-1.0) | Model's confidence in the contradiction assessment. Must be a float between 0.0 and 1.0 inclusive. Values below [CONFIDENCE_THRESHOLD] trigger retry or human review. | |
no_contradiction_explanation | string or null | Required when contradiction_detected is false. Brief explanation of why sources are consistent. Null when contradiction_detected is true. |
Common Failure Modes
What breaks first when detecting context contradictions and how to guard against it in production.
False Conflict Over Synonymy
What to watch: The model flags a contradiction when two sources use different terminology for the same concept (e.g., 'Q4 revenue' vs 'fourth quarter earnings'). This inflates false-positive escalations and wastes reviewer time. Guardrail: Add a pre-processing step that normalizes key entities and dates before contradiction detection, and include a 'semantic equivalence' check in the prompt instructions.
Temporal Context Collapse
What to watch: The model treats information from different time periods as conflicting when it actually reflects legitimate change over time (e.g., 'CEO was Alice in 2022' vs 'CEO is Bob in 2024'). This generates spurious escalations. Guardrail: Require the prompt to extract and compare publication dates or temporal markers from each source, and only flag contradictions when timestamps overlap or are absent.
Granularity Mismatch Misreads
What to watch: A general statement in one source and a specific exception in another are flagged as contradictory (e.g., 'All employees get stock options' vs 'Part-time contractors do not get stock options'). Guardrail: Instruct the model to classify the relationship as 'general-vs-specific' before declaring a contradiction, and only escalate when two claims at the same level of specificity directly conflict.
Source Authority Blindness
What to watch: The model treats all sources as equally authoritative, flagging a contradiction between a primary source and a low-quality aggregator without weighting credibility. Guardrail: Include source authority metadata (e.g., 'primary', 'verified', 'aggregator') in the prompt context and instruct the model to suppress contradiction flags when a high-authority source clearly supersedes a low-authority one.
Implicit vs Explicit Conflict Miss
What to watch: The model only catches direct contradictions ('Revenue is $10M' vs 'Revenue is $12M') but misses implied conflicts where one source's claim logically precludes another's without stating it outright. Guardrail: Add a reasoning step in the prompt that asks: 'If Source A is true, does Source B become impossible or highly unlikely?' before making a final contradiction determination.
Escalation Payload Overload
What to watch: The contradiction summary sent to human review includes full document text dumps, making it impossible for reviewers to quickly triage the actual conflict. Guardrail: Constrain the output schema to require a concise 'Conflict at a Glance' field with the two conflicting excerpts limited to 150 words each, plus a one-sentence summary of the disagreement before any supporting context.
Evaluation Rubric
Use this rubric to test the Context Contradiction Detection Prompt before deploying it in a production RAG pipeline. Each criterion targets a specific failure mode that degrades trust in automated contradiction detection.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Contradiction Recall | All human-annotated factual conflicts in the test set are detected and surfaced in the output | A known direct contradiction between two sources is missing from the contradiction_summary array | Run prompt against a golden dataset of 50+ context pairs with labeled contradictions; require recall >= 0.95 |
False Conflict Rate | No more than 5% of flagged contradictions are false positives where sources actually agree or address different scopes | Output flags a contradiction where sources use different terminology for the same fact or describe different time periods | Have two reviewers independently label 100 flagged contradictions as true or false; measure inter-annotator agreement and false positive ratio |
Source Attribution Accuracy | Every contradiction entry correctly cites the exact source_id and relevant excerpt from both conflicting sources | A contradiction entry references a source_id that does not exist in the provided context or misattributes a claim | Parse output against input context source_id list; verify each cited excerpt is a substring match in the referenced source |
Contradiction Type Classification | Each contradiction is assigned the correct type from the defined taxonomy with no misclassifications in the test set | A temporal conflict is labeled as a semantic conflict, or a numerical contradiction is labeled as an entity conflict | Compare predicted contradiction_type against human labels on 30 pre-classified contradiction examples; require accuracy >= 0.90 |
Severity Scoring Calibration | Severity scores correlate with human judgments of contradiction impact on decision-making or answer correctness | A contradiction that would change a critical answer is scored as low severity, or a trivial wording difference is scored as critical | Have 3 domain experts rank 20 contradictions by severity; measure Spearman rank correlation between model scores and median human rank |
Non-Contradiction Pass-Through | Prompt returns empty contradiction_summary when all sources are consistent, with no hallucinated conflicts | Output invents a contradiction not present in the sources or misinterprets complementary information as conflicting | Run prompt on 50 consistent context sets; require contradiction_summary to be an empty array in all cases |
Escalation Payload Completeness | Escalation output includes all required fields for human review without truncation or missing diagnostic context | Escalation payload is missing the diagnostic_context, affected_claims, or recommended_action fields when contradictions are found | Validate output against the defined output schema; reject any response where required fields are null or absent when contradictions exist |
Latency Under Load | Prompt completes within 2 seconds for context sets up to 10 sources and 5000 tokens | Response time exceeds 5 seconds or times out on typical production context sizes | Benchmark with 100 requests at varying context sizes; measure p95 latency and timeout rate |
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 simple JSON schema for contradiction output. Focus on recall over precision. Log all detections for manual review.
code[SYSTEM] You are a contradiction detector. Review the provided context chunks and identify any factual conflicts. [INPUT] Context chunks: [CHUNKS] [OUTPUT_SCHEMA] {"contradictions": [{"claim_a": "...", "source_a": "...", "claim_b": "...", "source_b": "...", "summary": "..."}]}
Watch for
- Missing schema checks leading to unparseable output
- Overly broad instructions catching stylistic differences as contradictions
- No confidence scoring, making triage impossible

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