This prompt operates as a post-extraction validation gate for entity resolution and graph construction pipelines. After an upstream model extracts entities and relationships from source text, this prompt reviews every proposed relationship edge and determines whether the source text actually supports the connection. Use it when your pipeline cannot tolerate hallucinated edges entering a knowledge graph, when downstream analytics depend on relationship accuracy, or when you need an audit trail of pruning decisions. This is not a replacement for the initial extraction prompt. It assumes you already have a set of extracted triples or relationship records and need to filter them before ingestion.
Prompt
Spurious Relationship Pruning Prompt for Entity Extraction

When to Use This Prompt
Defines the operational context for deploying a post-extraction validation gate that prunes hallucinated relationship edges before they enter a knowledge graph.
The ideal user is an engineering lead or data pipeline operator who already has a working extraction step but observes fabricated relationships in production—entities connected by relationships the model inferred rather than extracted. You should have the original source text and the extracted relationship set available as inputs. This prompt works best when each relationship carries a confidence marker or extraction rationale from the upstream model, giving the pruning step more signal to evaluate. Do not use this prompt when you lack the source text for comparison, when the extraction model already provides reliable grounding scores, or when your graph tolerates probabilistic edges with explicit uncertainty labels. In those cases, a simpler threshold filter or a human review queue may be more appropriate than a secondary LLM call.
Before wiring this into production, define your tolerance for false positives (removing valid relationships) versus false negatives (keeping hallucinated ones). The prompt includes a [CONSERVATIVENESS] parameter that lets you tune this trade-off. For high-stakes domains like legal contract analysis or clinical entity extraction, set conservativeness high and route borderline cases to human review. For exploratory knowledge graph construction where some noise is acceptable, lower conservativeness will preserve more edges. Always log pruning decisions with the justification text this prompt produces—that audit trail becomes essential when downstream consumers question why a relationship is missing from the graph.
Use Case Fit
Where the Spurious Relationship Pruning Prompt delivers value and where it creates unnecessary overhead.
Good Fit: Entity Resolution Pipelines
Use when: building knowledge graphs or entity resolution systems where extracted relationships must be grounded in source text. Guardrail: Run this prompt after initial extraction but before graph insertion to prevent hallucinated edges from corrupting downstream queries.
Good Fit: RAG Systems with Relationship Outputs
Use when: your RAG pipeline outputs entity-relationship triples alongside generated text. Guardrail: Pair this prompt with citation verification to ensure every relationship edge maps to a retrievable passage before surfacing to users.
Bad Fit: Unstructured Narrative Generation
Avoid when: your system produces free-text narratives without explicit relationship extraction. Guardrail: Use factual consistency checks instead; this prompt requires structured entity-relationship pairs as input and will add latency without benefit for prose outputs.
Required Inputs
What you need: extracted entity-relationship triples, the full source text those triples were derived from, and an optional confidence threshold. Guardrail: Without source text, the prompt cannot verify grounding and will either over-prune or under-prune based on surface plausibility alone.
Operational Risk: Over-Pruning Valid Relationships
What to watch: the model may remove relationships that are genuinely implied but not explicitly stated in a single sentence. Guardrail: Set a conservative pruning threshold and route borderline cases to human review rather than automatic deletion.
Operational Risk: Latency in High-Throughput Pipelines
What to watch: running this prompt on every extraction adds a full model round-trip per batch. Guardrail: Batch multiple relationship sets into a single prompt call, and skip pruning for extractions where the source text is too short to support spurious inference.
Copy-Ready Prompt Template
Paste this prompt into your entity extraction pipeline to prune spurious relationships before they enter your graph or database.
This prompt template is designed to sit between your entity extraction step and your graph ingestion step. It receives a list of extracted entities and their proposed relationships, along with the source text that should ground those relationships. The model's job is to audit each relationship, determine whether it is supported by the source text, and return only the relationships that have clear textual evidence. Use this when your extraction pipeline produces relationship edges that downstream systems treat as fact—such as knowledge graphs, investigative link charts, or compliance databases.
textYou are an evidence auditor for an entity extraction pipeline. Your task is to review a set of proposed relationships between entities and prune any relationship that is not directly supported by the provided source text. ## INPUT Source Text: [SOURCE_TEXT] Extracted Entities: [ENTITIES_JSON] Proposed Relationships: [RELATIONSHIPS_JSON] ## INSTRUCTIONS 1. For each proposed relationship, locate the exact span of text in the source that supports it. If no supporting span exists, mark the relationship for removal. 2. A relationship is supported only if the source text explicitly states or strongly implies the connection. Do not infer relationships from world knowledge, common sense, or statistical association. 3. If a relationship is partially supported (e.g., the entities co-occur but the specific relationship type is not stated), mark it as UNSUPPORTED. 4. Do not add new relationships. Only prune or keep the provided set. 5. If the source text is insufficient to verify any relationship, return an empty list and explain why. ## OUTPUT SCHEMA Return a JSON object with the following structure: { "kept_relationships": [ { "source_entity": "string", "target_entity": "string", "relationship_type": "string", "evidence_span": "string (exact quote from source)", "confidence": "HIGH | MEDIUM" } ], "removed_relationships": [ { "source_entity": "string", "target_entity": "string", "relationship_type": "string", "removal_reason": "NO_EVIDENCE | WEAK_IMPLICATION | ENTITY_NOT_IN_SOURCE | CONTRADICTED_BY_SOURCE" } ], "audit_summary": "Brief explanation of pruning decisions" } ## CONSTRAINTS - Do not fabricate evidence spans. If you cannot find a supporting quote, the relationship must be removed. - Preserve the original entity identifiers exactly as provided in [ENTITIES_JSON]. - If the source text is empty or unrelated to the entities, return all relationships as removed with reason NO_EVIDENCE. - For [RISK_LEVEL] = HIGH, require explicit, unambiguous textual support. For MEDIUM, allow strong implication.
Adaptation guidance: Replace [SOURCE_TEXT] with the raw document or passage that should ground the relationships. [ENTITIES_JSON] should contain the canonical entity list with IDs and types from your extraction step. [RELATIONSHIPS_JSON] should contain the proposed triples (source_entity, target_entity, relationship_type) that your extraction model produced. Set [RISK_LEVEL] to HIGH for regulated domains (legal, clinical, financial) where fabricated relationships carry compliance risk, or MEDIUM for exploratory graph construction where some noise is tolerable. The output schema is designed to feed directly into a graph database ingestion step—kept relationships go in, removed relationships go to a review queue or audit log.
Before shipping: Wire this prompt into a post-extraction validation harness. After the model returns the pruned relationship set, validate that every kept relationship's evidence_span is a substring of [SOURCE_TEXT] using an exact string match or fuzzy substring check. Log all removed relationships with their reasons for pipeline observability. For high-risk domains, route removed relationships with reason CONTRADICTED_BY_SOURCE to human review—these may indicate extraction errors upstream. Run this prompt against a golden dataset of source texts with known entity relationships to measure precision (did we keep only true relationships?) and recall (did we accidentally prune real ones?). Common failure mode: the model marks a relationship as supported but provides an evidence span that is a paraphrase rather than a quote—your substring validator will catch this.
Prompt Variables
Every placeholder the Spurious Relationship Pruning Prompt expects, why it matters, and how to validate it before sending. Validate each input to prevent the prompt from pruning real relationships or preserving hallucinated ones.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[SOURCE_TEXT] | The raw document or passage from which entities and relationships were originally extracted. This is the ground truth for pruning decisions. | Acme Corp. acquired Beta LLC for $200M in Q3 2023. The deal was led by CEO Alice Smith. | Must be a non-empty string. Check that the text is the exact source used for extraction, not a summary or a different version. If null or empty, abort the prompt; pruning without source text is unsafe. |
[EXTRACTED_ENTITIES] | The list of entities the model previously extracted from [SOURCE_TEXT]. Each entity should have an ID, name, and type. | [{"id": "E1", "name": "Acme Corp.", "type": "ORG"}, {"id": "E2", "name": "Beta LLC", "type": "ORG"}] | Must be a valid JSON array. Validate that each object has 'id', 'name', and 'type' fields. Reject if any entity ID referenced in [EXTRACTED_RELATIONSHIPS] is missing from this list. |
[EXTRACTED_RELATIONSHIPS] | The list of relationships between entities that the model previously extracted. Each relationship links two entity IDs and has a type. | [{"source": "E1", "target": "E2", "type": "ACQUIRED"}, {"source": "E1", "target": "E3", "type": "LED_BY"}] | Must be a valid JSON array. Validate that each object has 'source', 'target', and 'type' fields. Confirm that every 'source' and 'target' ID exists in [EXTRACTED_ENTITIES]. Reject if any relationship is a self-loop (source == target) unless explicitly allowed. |
[PRUNING_RULES] | A list of explicit rules that define what constitutes a spurious relationship. Rules can reference evidence requirements, entity co-occurrence, or forbidden relationship types. | ["A relationship is spurious if the two entities never co-occur in the same sentence or adjacent sentences in [SOURCE_TEXT].", "A relationship is spurious if its type is not explicitly stated or strongly implied by a verb or noun phrase in [SOURCE_TEXT]."] | Must be a non-empty JSON array of strings. Each rule must be a declarative, testable statement. Avoid vague rules like 'use common sense.' Validate that rules reference [SOURCE_TEXT] as the evidence base, not external knowledge. |
[OUTPUT_SCHEMA] | The exact JSON schema the pruned output must conform to. Defines the structure for the cleaned entity and relationship lists plus the pruning justification. | {"type": "object", "properties": {"entities": {"type": "array"}, "relationships": {"type": "array"}, "pruned_relationships": {"type": "array"}, "pruning_log": {"type": "array"}}, "required": ["entities", "relationships", "pruned_relationships", "pruning_log"]} | Must be a valid JSON Schema object. Validate that it includes required fields for both the kept and pruned relationships, plus a justification array. Reject schemas that allow dropping relationships without logging the reason. |
[CONFIDENCE_THRESHOLD] | A numeric threshold between 0.0 and 1.0. Relationships with a grounding confidence score below this threshold are candidates for pruning. | 0.7 | Must be a float between 0.0 and 1.0 inclusive. If set to 0.0, all relationships are kept regardless of confidence. If set to 1.0, only relationships with perfect grounding survive. Validate that the value is not null; default to 0.5 if unspecified but log a warning. |
[PRUNING_MODE] | Controls whether the prompt should be conservative (keep ambiguous relationships) or aggressive (prune anything not explicitly grounded). | conservative | Must be one of: 'conservative', 'aggressive', or 'balanced'. Validate against an enum. In 'conservative' mode, the prompt keeps relationships with partial evidence. In 'aggressive' mode, it prunes anything without explicit source text support. Reject unknown values. |
[MAX_RELATIONSHIPS] | The maximum number of relationships to return after pruning. Used to prevent output bloat when the source text is dense. | 50 | Must be a positive integer. If the number of grounded relationships exceeds this value, the prompt should prioritize the highest-confidence relationships. Validate that the value is not greater than the total relationships in [EXTRACTED_RELATIONSHIPS] unless expansion is intended. |
Implementation Harness Notes
How to wire the Spurious Relationship Pruning Prompt into a production entity extraction pipeline with validation, retries, and human review hooks.
This prompt is a post-extraction filter, not a standalone entity resolver. It expects a list of extracted relationships and their source texts as input. In production, wire it after your entity extraction step and before writing to your graph database or knowledge store. The prompt's job is to reject edges the model invented, not to add missing relationships. Keep the extraction step and the pruning step separate so you can tune each independently and log pruning decisions for audit.
Build a thin validation layer around the prompt call. The output schema should be a JSON array of relationship objects, each with relationship, verdict (one of PRESERVE or PRUNE), and evidence fields. Validate that every input relationship ID appears in the output exactly once, that no new IDs are introduced, and that verdict values are constrained to the allowed enum. If validation fails, retry once with the validation error injected into the prompt context. If the retry also fails, route the batch to a human review queue and log the failure with the raw model response and validator output. For high-stakes domains like legal or clinical entity graphs, require human approval on all PRUNE decisions before edges are removed from the graph.
Model choice matters here. This prompt requires strong instruction-following and low hallucination on structured comparison tasks. Claude 3.5 Sonnet and GPT-4o are good defaults. Avoid smaller or older models that may invent relationship verdicts or drop input entries. Set temperature to 0 and disable sampling to maximize deterministic pruning behavior. If you are processing large relationship batches, chunk the input into groups of 20-30 relationships per call to stay within reliable attention windows and to make retry scope manageable. Log every pruning decision with the model version, timestamp, and input hash so you can trace regressions if a model update changes pruning behavior.
Observability is critical because silent over-pruning breaks downstream graph queries. Emit metrics for: total relationships processed, number pruned, number preserved, validation failure rate, and retry rate. Set an alert if the prune ratio spikes above a historical baseline, which often indicates a prompt regression or a model behavior change. Store the full prompt and response for every call in a structured log so you can replay failures during debugging. If you are building a graph for search or analytics, consider keeping pruned relationships in a separate 'rejected edges' table with their evidence and verdict for periodic human audit rather than deleting them outright.
Expected Output Contract
The exact structure, field types, and validation rules your application should enforce on the model response after pruning spurious relationships. Use this contract to parse, validate, and reject malformed outputs before they enter your graph database or entity resolution pipeline.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
pruned_relationships | Array of objects | Must be a JSON array. If empty, return []. Schema check: each element must match the relationship object contract below. | |
pruned_relationships[].source_entity | String | Must exactly match an entity ID or name from the [INPUT_ENTITIES] list. Parse check: string match against input set. If no match, reject the relationship. | |
pruned_relationships[].target_entity | String | Must exactly match an entity ID or name from the [INPUT_ENTITIES] list. Parse check: string match against input set. If no match, reject the relationship. | |
pruned_relationships[].relationship_type | String | Must be a non-empty string. Enum check: value must appear in the [ALLOWED_RELATIONSHIP_TYPES] list if provided; otherwise, any non-empty string is accepted but logged for review. | |
pruned_relationships[].evidence_spans | Array of strings | Each string must be a verbatim substring from [SOURCE_TEXT]. Citation check: exact substring match required. Empty array means the relationship was retained by policy but lacks direct textual evidence—flag for human review. | |
pruned_relationships[].confidence | Number | Must be a float between 0.0 and 1.0 inclusive. Threshold check: relationships with confidence below [MIN_CONFIDENCE_THRESHOLD] should be routed to a review queue, not dropped silently. | |
removed_relationships | Array of objects | Must be a JSON array. Each object must include source_entity, target_entity, relationship_type, and removal_reason. Removal reason must be one of: 'no_evidence', 'contradicted_by_source', 'entity_not_found', 'below_confidence_threshold'. | |
processing_metadata | Object | Must include fields: total_input_relationships (integer), total_pruned_relationships (integer), total_removed_relationships (integer), and pruning_timestamp (ISO 8601 string). Schema check: all four fields required. Timestamp must parse as valid ISO 8601. |
Common Failure Modes
Spurious relationship pruning fails in predictable ways when the model confuses correlation with causation, invents connections from background knowledge, or overfits to ambiguous co-occurrence. These cards cover the most common production failure patterns and how to guard against each one.
Background Knowledge Contamination
What to watch: The model infers relationships between entities because it knows they are connected in the real world, not because the source text provides evidence. A prompt about a tech partnership may hallucinate acquisition details the model memorized from news articles. Guardrail: Add an explicit instruction that every relationship must be accompanied by a verbatim source quote. Reject any edge where the model cannot produce a direct textual citation.
Co-occurrence Mistaken for Causation
What to watch: Two entities appear in the same sentence or paragraph, and the model labels them as related even when the text describes them independently. For example, a paragraph listing competitors may be misinterpreted as describing a partnership. Guardrail: Require the model to classify the relationship type from a closed taxonomy and provide a confidence score. Flag and review all edges where the relationship type is ambiguous or the confidence is below a defined threshold.
Transitive Relationship Hallucination
What to watch: The model chains multiple real relationships into an invented one. If the text says A works with B and B works with C, the model may incorrectly assert A works with C. Guardrail: Constrain the prompt to extract only direct, explicitly stated relationships. Add a post-processing rule that removes any edge where the source quote does not contain both entities in the same relationship context.
Pronoun and Coreference Resolution Errors
What to watch: The model resolves a pronoun or indirect reference to the wrong entity, creating a spurious relationship. "It announced the deal" may be attached to the wrong organization when multiple entities are in scope. Guardrail: Instruct the model to resolve all pronouns and references explicitly before extracting relationships, and to mark any edge where coreference is ambiguous for human review.
Negation and Hypothetical Misinterpretation
What to watch: The model extracts a relationship from a negated or hypothetical statement as if it were factual. "The companies did not merge" or "If they partner next year" may still produce a merger or partnership edge. Guardrail: Add a pre-extraction step that identifies negated, hypothetical, and speculative language. Exclude any relationship where the source statement is modal, conditional, or explicitly negated.
Temporal Scope Drift
What to watch: The model extracts a relationship that was true in the past but is no longer active, or describes a future possibility as a current fact. A document mentioning a former CEO may produce a current employment relationship. Guardrail: Require temporal grounding for every edge—when was the relationship true according to the text. Flag edges where the temporal scope is past, future, or unspecified, and exclude them from the current-state graph unless explicitly needed.
Evaluation Rubric
How to test output quality before shipping. Run these checks against a labeled golden dataset of relationships with known ground-truth verdicts.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Spurious Relationship Recall |
| Flagged relationships remain in the pruned output; false negatives exceed 5% | Compare pruned output against golden dataset labels; count missed spurious edges |
Valid Relationship Precision |
| Valid relationships are incorrectly removed; false positives exceed 2% | Compare preserved relationships against golden dataset labels; count incorrectly pruned valid edges |
Removal Justification Quality | Every removal includes a non-empty reason code matching [REASON_CODES] enum | Missing reason code, null justification, or code outside allowed enum values | Schema validation: assert reason_code field is present, non-null, and in allowed enum set |
Source Grounding Fidelity | Every preserved relationship cites at least one source span from [SOURCE_TEXT] that supports it | Preserved relationship has empty source_spans array or spans that do not appear in source text | Span offset verification: check that each cited span substring exists in the original source text |
Output Schema Compliance | Output matches [OUTPUT_SCHEMA] exactly: all required fields present, no extra fields, correct types | Missing required fields, extra hallucinated fields, or type mismatches in relationship objects | JSON Schema validation against [OUTPUT_SCHEMA]; reject on any schema violation |
Confidence Threshold Adherence | No relationship with confidence_score below [CONFIDENCE_THRESHOLD] appears in preserved output | Low-confidence relationships appear in preserved set without being flagged for review | Filter preserved relationships: assert all have confidence_score >= [CONFIDENCE_THRESHOLD] |
Edge Case: Ambiguous Relationships | Relationships marked as ambiguous in golden dataset are either flagged for human review or pruned conservatively | Ambiguous relationships silently preserved without review flag or justification | Spot-check ambiguous golden cases: assert review_required is true or relationship is pruned |
Edge Case: Implicit Relationships | Relationships inferable but not explicitly stated are flagged with evidence_strength of 'implicit' and not treated as grounded | Implicit relationships marked as 'explicit' or 'grounded' without qualifying language | Check evidence_strength field on implicit golden cases: assert value is 'implicit' or relationship is pruned |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a single source document and a small set of extracted entities. Run the pruning pass as a separate LLM call after extraction. Keep the output format simple: return the original triple list with a spurious boolean flag and a one-line reason.
Add a lightweight post-check: if the model flags more than 50% of relationships as spurious, re-run with a lower confidence threshold or review the extraction prompt for systemic issues.
Watch for
- Over-pruning when the model is overly conservative and removes legitimate inferred relationships that are actually supported by the text
- Missing schema checks on the output—ensure the
reasonfield is always populated - The model treating co-occurrence as evidence when the source text only mentions entities in proximity without a stated relationship

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