This prompt is designed for summarization pipeline operators who need to verify that a generated summary does not introduce fabricated people, organizations, locations, or products. The core job-to-be-done is automated factuality gating: before a summary reaches a user, database, or downstream system, you compare its named entities against a provided source document and receive a structured diff report. The ideal user is an engineering lead or ML engineer integrating this check into a post-generation validation harness for RAG systems, meeting intelligence tools, or document processing pipelines where entity-level accuracy is a hard requirement.
Prompt
Entity Hallucination Detection Prompt for Summaries

When to Use This Prompt
Define the job, ideal user, and constraints for the Entity Hallucination Detection Prompt for Summaries.
Use this prompt when you have a single source document and a single summary, and you need a machine-readable report of which entities are grounded, which are hallucinated, and which are partial matches. It is not suitable for multi-document synthesis without adaptation—you would need to provide a merged source context or run the check per source. It is also not a replacement for human review in high-risk domains like healthcare or legal; the output should be treated as a triage signal that flags potential fabrications for human verification. The prompt includes threshold controls for fuzzy matching, allowing you to tune how aggressively it flags near-matches as hallucinations.
Before wiring this into production, define your tolerance for false positives and false negatives. A strict threshold may flag legitimate paraphrases or alternate names as hallucinations; a loose threshold may let invented entities slip through. Start by running this prompt against a golden dataset of known-good and known-bad summaries to calibrate the threshold. The output schema is designed to be consumed by a validation harness that can block, flag, or route summaries based on the hallucination count and severity. Do not use this prompt as the sole defense in regulated workflows—always pair it with human review for high-severity flags.
Use Case Fit
Where the Entity Hallucination Detection Prompt delivers value and where it introduces risk. This prompt is a post-generation audit tool, not a real-time filter.
Good Fit: RAG Summarization Pipelines
Use when: A summary is generated from a known set of source documents and must be verified for entity integrity before reaching the user. Guardrail: Always provide the full source text alongside the summary in the prompt harness. Without it, the model cannot ground its diff.
Bad Fit: Real-Time Chat Moderation
Avoid when: You need sub-second latency to block a message before it is displayed. This prompt requires both the source and the summary, making it a post-hoc audit. Guardrail: Use this in an asynchronous validation queue after response generation, not as a synchronous pre-display gate.
Required Inputs: Source-Output Pair
Risk: Running the prompt without the original source document forces the model to guess what is grounded, leading to unreliable diffs. Guardrail: The prompt harness must enforce two required variables: [SOURCE_DOCUMENT] and [GENERATED_SUMMARY]. Abort the check if either is missing.
Operational Risk: Partial Match Ambiguity
Risk: Fuzzy or partial entity matches (e.g., 'IBM' vs 'International Business Machines') can cause false positives or negatives in the hallucination report. Guardrail: Implement a configurable [SIMILARITY_THRESHOLD] parameter in the prompt and tune it against a golden dataset of known aliases before production deployment.
Operational Risk: High Token Consumption
Risk: Passing the entire source document and summary for every check doubles the context length, significantly increasing cost and latency for long documents. Guardrail: Pre-chunk the source document and run entity verification only on the specific chunks that map to the summary's cited sections, rather than the whole document at once.
Bad Fit: Open-Domain Creative Writing
Avoid when: The summary is intended to be abstractive, inferential, or creative rather than strictly extractive. The prompt will flag legitimate synthesis as hallucination. Guardrail: Only apply this prompt to use cases defined as 'extractive' or 'abstractive-with-grounding' in your product spec. Do not use it for creative or editorial workflows.
Copy-Ready Prompt Template
A reusable prompt template that compares named entities in a summary against a source document, flags invented entities, and returns a structured diff report.
The prompt below is designed to be dropped into a post-summarization validation step. It takes a source document and a generated summary as inputs, extracts all named entities from both, and produces a diff that identifies entities present in the summary but absent from the source. Use this template when you need automated hallucination detection before summaries reach end users, databases, or downstream systems. The prompt expects square-bracket placeholders to be filled by your application harness before each call.
textYou are an entity validation auditor. Your task is to compare named entities in a summary against the source document and identify any entities the summary invented. [INPUT] SOURCE DOCUMENT: """ [SOURCE_TEXT] """ GENERATED SUMMARY: """ [SUMMARY_TEXT] """ [CONTEXT] ENTITY TYPES TO CHECK: [ENTITY_TYPES] PARTIAL MATCH THRESHOLD: [MATCH_THRESHOLD] [OUTPUT_SCHEMA] Return a JSON object with this exact structure: { "source_entities": [ { "entity_text": "string", "entity_type": "string", "first_occurrence_offset": number } ], "summary_entities": [ { "entity_text": "string", "entity_type": "string", "first_occurrence_offset": number } ], "hallucinated_entities": [ { "entity_text": "string", "entity_type": "string", "summary_offset": number, "closest_source_match": "string or null", "match_similarity": number, "confidence": "high" | "medium" | "low" } ], "partial_matches": [ { "summary_entity": "string", "source_entity": "string", "similarity_score": number, "match_type": "fuzzy" | "alias" | "abbreviation" } ], "audit_summary": { "total_source_entities": number, "total_summary_entities": number, "hallucinated_count": number, "partial_match_count": number, "hallucination_rate": number } } [CONSTRAINTS] 1. Extract entities only of the types specified in [ENTITY_TYPES]. If [ENTITY_TYPES] is empty or "all", extract PERSON, ORGANIZATION, LOCATION, PRODUCT, DATE, MONEY, and EVENT entities. 2. For each entity in the summary, search for an exact or partial match in the source. Use the [MATCH_THRESHOLD] value (0.0 to 1.0) to determine when a partial match is close enough to consider grounded. 3. If [MATCH_THRESHOLD] is not provided, default to 0.85. 4. Flag any summary entity with no match above the threshold as hallucinated. 5. For hallucinated entities, set confidence to "high" if no source entity is remotely similar, "medium" if a weak partial match exists below threshold, and "low" if the entity type is ambiguous. 6. Include partial matches in the partial_matches array even when they fall below the threshold, so reviewers can assess borderline cases. 7. Do not flag entities that appear in the source under a different name if the match similarity exceeds the threshold. 8. Preserve all offsets as character positions from the start of the respective text. 9. If the summary contains no entities of the specified types, return empty arrays with audit_summary counts set to zero. 10. Do not invent entities. Only report what is present in the texts. [EXAMPLES] [FEW_SHOT_EXAMPLES] [RISK_LEVEL] Risk level: [RISK_LEVEL] If risk level is "high", include a "requires_human_review" boolean field set to true in the audit_summary when hallucination_rate exceeds 0.1 or any hallucinated entity has confidence "high".
To adapt this template, replace each square-bracket placeholder with values from your application context. [SOURCE_TEXT] and [SUMMARY_TEXT] are the two required text inputs. [ENTITY_TYPES] accepts a comma-separated list like "PERSON, ORGANIZATION, LOCATION" or the keyword "all". [MATCH_THRESHOLD] controls how aggressively the prompt flags near-matches as grounded versus hallucinated—lower values are more permissive. [FEW_SHOT_EXAMPLES] should contain one or two example input-output pairs showing correct entity extraction and flagging behavior for your domain. [RISK_LEVEL] accepts "low", "medium", or "high" and gates whether the output includes a mandatory human-review flag. Wire this prompt into a post-summarization pipeline where the source document is always available, and never run it without providing both texts—the prompt cannot detect hallucinations from the summary alone.
Prompt Variables
Required inputs for the Entity Hallucination Detection Prompt. Each placeholder must be populated before the prompt is sent. Missing or malformed inputs are the most common cause of false negatives in hallucination detection.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[SOURCE_DOCUMENT] | The original source text that the summary was derived from. Serves as ground truth for entity verification. | Full text of a 10-K filing section, a meeting transcript, or a research paper abstract. | Required. Must be non-empty string. Truncation beyond model context window will cause false negatives for entities in truncated portion. |
[SUMMARY_TEXT] | The model-generated summary to audit for hallucinated entities. This is the suspect output under review. | A 3-paragraph executive summary generated by a prior model call. | Required. Must be non-empty string. If summary is empty or null, return error before prompt execution. Do not pass empty summaries. |
[ENTITY_TYPES] | Comma-separated list of named entity types to check. Controls scope and prevents false positives on irrelevant entity categories. | PERSON, ORGANIZATION, LOCATION, PRODUCT | Required. Must match supported types: PERSON, ORGANIZATION, LOCATION, PRODUCT, DATE, MONEY, PERCENT, EVENT, WORK_OF_ART, LAW. Unknown types should be stripped with a warning logged. |
[PARTIAL_MATCH_THRESHOLD] | Float between 0.0 and 1.0 controlling fuzzy match sensitivity for entity comparison. Lower values flag more partial matches as suspect. | 0.85 | Required. Must be a float between 0.0 and 1.0. Values below 0.7 produce high false-positive rates. Values above 0.95 miss legitimate partial matches. Default 0.85 if not specified. |
[OUTPUT_FORMAT] | Specifies the structure of the diff report. Controls whether output is a flat list, grouped by entity type, or a full audit matrix. | grouped_by_type | Required. Must be one of: flat_list, grouped_by_type, audit_matrix. Invalid values should cause a pre-flight rejection with a clear error message. |
[INCLUDE_CONFIDENCE_SCORES] | Boolean controlling whether each flagged entity includes a confidence score. Useful for downstream filtering pipelines. | Required. Must be true or false. When true, each flagged entity must include a confidence field between 0.0 and 1.0. When false, only the verdict and matched source entity are returned. | |
[SOURCE_GROUNDING_REQUIRED] | Boolean controlling whether every entity in the summary must have an explicit source match. When true, unmatched entities are flagged even if they seem plausible. | Required. Must be true or false. When true, the prompt enforces strict grounding. When false, entities without source matches are noted but not flagged as hallucinations. Use true for regulated domains. |
Implementation Harness Notes
How to wire the Entity Hallucination Detection prompt into a production summarization pipeline with validation, retries, and human review gates.
This prompt is designed to operate as a post-generation validation step within a summarization pipeline. It should be called immediately after a summary is produced, receiving both the generated summary and the source document as inputs. The prompt's output—a structured diff report of matched, unmatched, and partial-match entities—should be parsed by your application to determine whether the summary passes quality gates or requires remediation. Do not treat this as a one-shot check; integrate it as a mandatory stage before any summary reaches a user-facing surface, database, or downstream system.
Wire the prompt into your application with a clear harness: define [SUMMARY] and [SOURCE_DOCUMENT] as required string inputs, and set [MATCH_THRESHOLD] to a float between 0.0 and 1.0 (start at 0.8 for strict matching). Parse the JSON output into a structured object with fields for matched_entities, unmatched_entities, and partial_match_entities. Implement a validation layer that rejects malformed JSON and triggers a retry with the same inputs. If unmatched entities exceed a configurable threshold (e.g., more than 2 invented entities or any invented entity in a high-risk domain), route the summary to a human review queue rather than auto-publishing. Log every detection result—including the summary ID, source document ID, entity counts, and the full diff—for audit trails and prompt performance monitoring over time.
For model selection, use a model with strong instruction-following and structured output capabilities. Avoid models prone to hallucination in their own right for this verification task. Set temperature to 0 or a very low value to maximize deterministic entity extraction. If your pipeline processes high-volume summaries, consider batching multiple summary-source pairs into a single call with clear delimiters, but test thoroughly for cross-contamination between batches. Implement a circuit breaker: if the detection prompt itself fails or returns invalid JSON three consecutive times, escalate to on-call engineering and halt the affected pipeline segment. Never allow a summary with unverified entity provenance to bypass this check silently—the cost of a hallucinated entity in a customer-facing summary far exceeds the latency of a verification step.
Expected Output Contract
Defines the exact structure, types, and validation rules for the entity hallucination detection report. Use this contract to parse, validate, and store the model output before downstream consumption.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
summary_id | string | Must match the [SUMMARY_ID] input exactly. Non-null, non-empty. Reject on mismatch. | |
source_entity_count | integer | Must be >= 0. Must equal the count of entities in the source_entities array. Reject on mismatch. | |
summary_entity_count | integer | Must be >= 0. Must equal the count of entities in the summary_entities array. Reject on mismatch. | |
entities | array of objects | Must be a JSON array. Each element must conform to the entity object schema below. Reject if not an array. | |
entities[].name | string | Non-empty string. The entity text as it appears in the summary. Trim whitespace before validation. | |
entities[].type | enum string | Must be one of: PERSON, ORGANIZATION, LOCATION, PRODUCT, DATE, OTHER. Reject unknown values. | |
entities[].status | enum string | Must be one of: MATCHED, PARTIAL_MATCH, HALLUCINATED. Reject unknown values. | |
entities[].matched_source_entity | string or null | If status is MATCHED or PARTIAL_MATCH, must be a non-empty string matching an entity in the source document. If status is HALLUCINATED, must be null. Reject on violation. | |
entities[].confidence | number | Must be a float between 0.0 and 1.0 inclusive. Reject values outside range. Reject non-numeric values. | |
entities[].evidence_span | string or null | If status is MATCHED, should contain the exact source text span supporting the match. If null, no evidence was extractable. Null allowed. | |
hallucination_rate | number | Must be a float between 0.0 and 1.0 inclusive. Must equal (hallucinated_entity_count / summary_entity_count). Reject on arithmetic mismatch. | |
hallucinated_entity_count | integer | Must be >= 0. Must equal the count of entities with status HALLUCINATED. Reject on mismatch. | |
audit_timestamp | ISO 8601 string | Must parse as a valid ISO 8601 datetime string. Reject unparseable timestamps. |
Common Failure Modes
Entity hallucination in summaries breaks trust and downstream processing. These are the most frequent failure patterns when comparing named entities in a summary against source documents, with concrete mitigations for each.
Partial Match False Positives
What to watch: The model flags entities as hallucinated because of minor string differences—'IBM Corp.' vs 'IBM', 'Joe Biden' vs 'President Biden', or abbreviation mismatches. This floods the diff report with noise and buries real hallucinations. Guardrail: Implement a fuzzy matching threshold with normalization (lowercase, strip punctuation, expand common abbreviations) before entity comparison. Only flag entities below a configurable similarity score.
Coreference Resolution Gaps
What to watch: The summary uses pronouns or alternate references ('the company,' 'the CEO,' 'the acquisition') that refer to entities in the source, but the detection prompt treats them as missing because the surface form doesn't match any extracted entity. Guardrail: Pre-process the summary with a coreference resolution step, or instruct the detection prompt to resolve anaphoric references against the source before comparing entity lists.
Nested Entity Over-Flagging
What to watch: Compound entities like 'Google's DeepMind division' or 'the FDA's Center for Drug Evaluation' get flagged because 'DeepMind division' or 'Center for Drug Evaluation' don't appear independently in the source entity list. Guardrail: Build hierarchical entity containment checks—if a nested entity is fully contained within a source entity span, treat it as grounded rather than hallucinated.
Temporal Entity Drift
What to watch: The summary references entities that were correct at the time of source publication but are now outdated—renamed companies, merged organizations, or people who changed roles. The detection prompt flags these as hallucinations when they're actually stale references. Guardrail: Include a temporal context window in the prompt that distinguishes between 'entity not in source' and 'entity may have changed since source publication.' Flag the latter for human review rather than automatic removal.
Entity Boundary Ambiguity
What to watch: The model disagrees with itself about where an entity starts and ends—'San Francisco Bay Area' vs 'San Francisco' vs 'Bay Area'—causing inconsistent matching and phantom hallucination flags. Guardrail: Standardize entity extraction with a fixed entity type taxonomy (PERSON, ORG, LOC, PRODUCT) and consistent span rules before running the diff. Use the same extraction prompt for both source and summary to reduce boundary drift.
Threshold Tuning Drift Across Domains
What to watch: A similarity threshold calibrated on news articles fails on legal contracts or clinical notes where entity precision requirements differ. Legal documents need exact name matching; news summaries tolerate more variation. Guardrail: Expose the similarity threshold as a configurable parameter in the prompt harness, and maintain domain-specific presets. Log threshold decisions alongside flagged entities for auditability and tuning.
Evaluation Rubric
Use this rubric to test the Entity Hallucination Detection Prompt before deploying it in a production summarization pipeline. Each criterion targets a specific failure mode that breaks downstream trust.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
True Positive Detection | All invented entities in the summary are flagged with a hallucination status of true. | A known fabricated entity is not present in the diff report or is incorrectly marked as grounded. | Inject a summary containing a person, org, and location not in the source. Verify all three appear in the flagged list. |
True Negative Rate | No entity genuinely extracted from the source document is flagged as a hallucination. | A source-derived entity appears in the flagged list with a hallucination status of true. | Use a clean summary with only source entities. Assert the flagged list is empty or all statuses are false. |
Partial Match Handling | Fuzzy matches above the [SIMILARITY_THRESHOLD] are classified as grounded, not hallucinated. | A minor typo or abbreviation variant triggers a hallucination flag. | Provide a summary with 'IBM Corp.' when the source contains 'International Business Machines'. Verify it is not flagged if the threshold is set reasonably. |
Output Schema Compliance | The output is valid JSON matching the [OUTPUT_SCHEMA] exactly, including the diff_report array. | The response is a markdown table, plain text, or JSON missing the required entity_status field. | Parse the raw model response with a JSON validator. Check for required fields: entity_name, entity_type, hallucination_status, source_span. |
Empty Summary Handling | An empty or null [SUMMARY] input returns a valid diff report with zero flagged entities and no errors. | The model hallucinates entities from its training data or returns a parsing error. | Pass an empty string or null for [SUMMARY]. Assert the flagged_entities array is empty and no error field is populated. |
Source-Only Entity Exclusion | Entities present only in the source but not in the summary are excluded from the diff report. | The report flags an entity as hallucinated simply because it is missing from the summary. | Provide a source with 5 entities and a summary mentioning only 3. Assert the report contains exactly 3 entities and 0 are flagged as hallucinated. |
Ambiguous Pronoun Resolution | Pronouns resolved to an entity in the summary are not flagged if the antecedent is clear in the source. | A correctly resolved pronoun like 'the company' is flagged as a hallucinated entity. | Use a summary that refers to a source entity by a pronoun. Verify the entity is not flagged if the resolution is unambiguous. |
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 small test set of 10-20 summary-source pairs. Use a frontier model (GPT-4o, Claude 3.5 Sonnet) with default temperature 0. Remove the strict JSON output schema and ask for a human-readable diff first—this makes iteration faster. Replace [ENTITY_TYPES] with a short list like ['PERSON', 'ORGANIZATION', 'LOCATION']. Skip the partial-match threshold control initially.
codeCompare the entities in [SUMMARY] against [SOURCE_DOCUMENT]. List any entities in the summary that do NOT appear in the source. Group by entity type.
Watch for
- The model being too lenient with fuzzy name matches (e.g., 'IBM Corp' vs 'IBM')
- Missing entities that are implied but not explicitly named
- Over-flagging common abbreviations as hallucinations
- No structured output means manual review is required

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