Inferensys

Prompt

Claim Extraction and Evidence Matching Trace Prompt

A practical prompt playbook for using Claim Extraction and Evidence Matching Trace Prompt in production AI workflows.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Understand the job-to-be-done, ideal user, required context, and limitations of the Claim Extraction and Evidence Matching Trace Prompt.

This prompt is designed for evaluation dataset builders and RAG quality engineers who need to construct a structured claim-evidence mapping from a single production trace. The task is to decompose a generated answer into atomic, verifiable claims and then attempt to match each claim to a specific retrieved passage captured in the trace. The output is a table that links each claim to its supporting evidence, a match confidence score, and a pointer to the trace span. Use this prompt when you are building a golden dataset for hallucination detection, calibrating an LLM judge, or auditing a RAG system's grounding behavior. It assumes you already have a trace containing the user query, the retrieved context chunks with their trace span IDs, and the final generated answer.

This prompt is not a real-time guardrail; it is a batch analysis tool for offline quality engineering. Do not use it in a synchronous request path where latency matters, as the decomposition and matching process is token-intensive and requires careful review. It is also not a substitute for human annotation when building high-stakes evaluation sets—treat its output as a first pass that requires human verification, especially for claims with low match confidence scores or complex multi-hop reasoning. The prompt works best with traces that have clean, attributable span IDs and retrieved passages that are self-contained enough to evaluate independently. If your traces lack span-level granularity or your retrieved context is heavily truncated, the evidence matching step will produce unreliable results.

Before running this prompt at scale, validate its output against a small set of manually annotated traces to calibrate your confidence thresholds. Pay special attention to claims that the model marks as 'supported' with low confidence—these are often cases where the retrieved passage is semantically related but does not actually entail the claim. After generating the claim-evidence table, use it to populate an evaluation dataset, feed it into a hallucination classifier, or identify systematic retrieval gaps. If you find that more than 20% of claims cannot be matched to any retrieved passage, investigate whether your retrieval pipeline is failing, your chunking strategy is too coarse, or the knowledge base itself has coverage gaps.

PRACTICAL GUARDRAILS

Use Case Fit

This prompt is designed for building evaluation datasets by extracting atomic claims and mapping them to trace evidence. It is not a runtime monitoring tool. Understand where it excels and where it introduces risk.

01

Good Fit: Offline Eval Dataset Curation

Use when: You are building a golden dataset for RAG faithfulness evaluation and need structured claim-evidence pairs with trace span pointers. Guardrail: Run this prompt over a representative sample of production traces, not live traffic, to avoid latency impact.

02

Bad Fit: Real-Time Guardrailing

Avoid when: You need to block a hallucinated response before it reaches the user. This prompt requires the full trace and generation to already exist. Guardrail: Use this prompt's output schema to train a faster classifier or define a runtime check, but do not put this in the critical path.

03

Required Inputs: Complete Trace Data

What to watch: The prompt fails silently if retrieval spans, context windows, or tool-call outputs are missing from the trace. Guardrail: Validate that the trace contains retrieval.documents, generation.text, and span IDs before invoking. Reject incomplete traces with a clear error code.

04

Operational Risk: High Token Consumption

What to watch: Processing long generations with many retrieved documents can consume significant context window space, leading to truncation or high cost. Guardrail: Chunk generations with more than N claims into separate calls. Set a hard token budget per trace and log cost attribution per evaluation run.

05

Operational Risk: Subjective Match Confidence

What to watch: The model's confidence score for evidence matching can be poorly calibrated, leading to false positives in the eval dataset. Guardrail: Treat match confidence as a ranking signal, not a decision threshold. Always include a human review step for claims below a calibrated confidence score before adding them to a golden dataset.

06

Bad Fit: Unstructured or Non-RAG Traces

Avoid when: The trace does not follow a standard RAG structure with clearly separated retrieval and generation steps, such as in free-form chat or pure tool-use agents. Guardrail: Implement a trace schema check first. If the trace format is unknown, use a more generic hallucination detection prompt instead of this evidence-matching specialist.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt that extracts atomic claims from a generated answer and maps each to a specific retrieved passage in the trace.

This template is the core instruction set for building an evaluation dataset. It takes a generated answer and the full retrieval trace as input, then decomposes the answer into discrete, verifiable claims. For each claim, it attempts to locate the exact supporting passage from the retrieved context, providing a match confidence score and a precise trace span pointer. Use this prompt when you need to quantify grounding at a granular level, not just a binary faithful/unfaithful label.

text
You are an expert trace auditor. Your task is to extract every atomic, factual claim from a generated answer and match each claim to a specific retrieved passage in the provided trace.

## INPUT
[ANSWER]
[TRACE_DATA]

## OUTPUT_SCHEMA
Return a single JSON object with the key "claim_evidence_map", which is an array of objects. Each object must have the following fields:
- "claim_id": string (unique identifier, e.g., "C1")
- "claim_text": string (the exact atomic claim from the answer)
- "match_status": "MATCHED" | "UNSUPPORTED" | "CONTRADICTED"
- "matched_passage_text": string | null (the verbatim text from the trace that supports the claim)
- "trace_span_id": string | null (the unique identifier for the trace span containing the passage)
- "confidence_score": number (0.0 to 1.0, indicating how well the passage supports the claim)
- "reasoning": string (brief explanation of the match status and score)

## CONSTRAINTS
- Decompose the answer into the smallest possible factual claims. Do not group multiple facts into one claim.
- A claim is "UNSUPPORTED" if no retrieved passage provides evidence for it.
- A claim is "CONTRADICTED" if a retrieved passage directly refutes it.
- The "matched_passage_text" must be a direct quote from the [TRACE_DATA].
- The "trace_span_id" must be the exact identifier from the trace, not an invented one.
- If a claim is UNSUPPORTED or CONTRADICTED, set "matched_passage_text" and "trace_span_id" to null.
- Do not hallucinate trace spans or passage text.

## EXAMPLES
[EXAMPLES]

## RISK_LEVEL
[RISK_LEVEL]

To adapt this template, replace the placeholders with your specific data. [ANSWER] should contain the full text of the model's generated response. [TRACE_DATA] must be a structured representation of the retrieval step, including the text of each retrieved chunk and its unique span ID. The [EXAMPLES] placeholder is critical for performance; provide 2-3 few-shot examples that demonstrate the difference between a MATCHED, UNSUPPORTED, and CONTRADICTED claim, especially showing how to handle partial matches. Set [RISK_LEVEL] to "HIGH" to trigger stricter confidence thresholds and more conservative matching in the model's internal reasoning. After generation, always validate the output JSON against the schema and verify that every trace_span_id in a MATCHED claim exists in the input [TRACE_DATA].

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Claim Extraction and Evidence Matching Trace Prompt. Each placeholder must be populated from production trace data before the prompt is executed.

PlaceholderPurposeExampleValidation Notes

[GENERATED_ANSWER]

The full generated output from the model that requires claim extraction and evidence matching

The patient's blood pressure was 140/90 mmHg, indicating stage 1 hypertension based on the provided lab results.

Must be a non-empty string. Truncated or incomplete answers will produce incomplete claim extraction. Validate length > 0 before prompt assembly.

[RETRIEVED_PASSAGES]

Array of retrieved context passages from the trace, each with content and trace span identifiers

[{"passage_id": "doc_12_span_3", "content": "Blood pressure reading: 140/90 mmHg taken on 2024-03-15.", "trace_span_id": "retrieval_span_42"}]

Must be a valid JSON array with at least one passage object. Each object requires passage_id, content, and trace_span_id fields. Null or empty array triggers abstention path.

[TRACE_ID]

Unique identifier for the production trace being analyzed, used for output traceability and debugging

trace_2025_01_15_14_32_abc123

Must be a non-empty string matching the trace system's identifier format. Used to anchor all output references back to the source trace. Validate against trace storage before processing.

[OUTPUT_SCHEMA]

Expected JSON schema for the claim-evidence mapping table output

{"claims": [{"claim_text": "...", "matched_passage_id": "...", "match_confidence": 0.92, "trace_span_id": "...", "match_status": "supported"}]}

Must be a valid JSON Schema object. Schema must include fields for claim_text, match_status (supported|unsupported|partial), match_confidence (0.0-1.0), and trace_span_id. Validate schema parse before prompt execution.

[CONFIDENCE_THRESHOLD]

Minimum confidence score for classifying a claim as supported versus unsupported or partial

0.75

Must be a float between 0.0 and 1.0. Claims below this threshold are flagged as unsupported or partial. Default 0.75 if not specified. Validate range before use.

[MAX_CLAIMS_PER_ANSWER]

Upper bound on the number of atomic claims to extract from the generated answer

20

Must be a positive integer. Prevents unbounded extraction on long outputs. Claims beyond this limit are noted in output metadata. Validate as integer > 0.

[ABSTENTION_FLAG]

Boolean indicating whether the model abstained from answering in the original trace

Must be true or false. When true, claim extraction is skipped and output records the abstention event with trace reference. Validate boolean type before prompt assembly.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the claim extraction and evidence matching prompt into a reliable evaluation pipeline.

This prompt is designed to be a component in an offline evaluation pipeline, not a real-time user-facing feature. The primary integration point is a batch processing job that reads production traces—each containing a generated answer, the retrieved context, and trace span metadata—and produces a structured claim-evidence mapping table. The output is consumed by evaluation dashboards, dataset builders, and regression testing frameworks that compare grounding quality across prompt versions or model upgrades.

Wire the prompt into a Python or Node.js worker that iterates over serialized trace objects. For each trace, construct the prompt by injecting the generated answer into [GENERATED_ANSWER], the full list of retrieved passages with their trace span IDs into [RETRIEVED_PASSAGES], and any domain-specific taxonomy or constraint notes into [DOMAIN_CONTEXT]. Set [CONFIDENCE_THRESHOLD] to a float between 0.0 and 1.0—typically 0.7 for initial runs—to filter low-confidence matches. The model should be instructed to return a strict JSON array of claim objects. Validate the response immediately: check that claim_id values are unique, that every matched_passage_id exists in the input passage list, that match_confidence is a float, and that trace_span_id is present for matched claims. If validation fails, retry once with the validation error appended to the prompt as additional context. Log all validation failures and retries to your observability platform with the trace ID attached.

For high-stakes evaluation datasets—such as those used to gate a model upgrade or certify a RAG pipeline for regulated use—add a human review step. After the prompt produces the claim-evidence mapping, route claims with match_confidence below 0.9 or with match_status set to conflict or partial to a review queue. Reviewers should confirm or correct the mapping before the record enters the golden dataset. Store the final mapping alongside the original trace in your evaluation database, indexed by trace ID and prompt version. Avoid running this prompt on streaming or synchronous user request paths; the extraction and matching step adds latency and token cost that belongs in the evaluation layer, not the serving layer.

IMPLEMENTATION TABLE

Expected Output Contract

The output of the Claim Extraction and Evidence Matching Trace Prompt is a structured JSON object. Each field must conform to the types, requirements, and validation rules below to be safely consumed by downstream evaluation pipelines or dashboards.

Field or ElementType or FormatRequiredValidation Rule

claims

Array of objects

Must be a non-empty array. If no claims are extractable, return an empty array, not null.

claims[].claim_id

String

Must be a unique identifier within the response, formatted as 'claim-<index>' starting from 0.

claims[].claim_text

String

Must be an atomic, self-contained factual statement extracted from the [GENERATED_ANSWER]. Cannot be empty or whitespace-only.

claims[].matched_passage_id

String or null

Must be a valid span_id from the [TRACE_SPANS] if a match is found. Must be null if no passage supports the claim.

claims[].match_confidence

Number

Must be a float between 0.0 and 1.0. A value of 0.0 is required when matched_passage_id is null. Values > 0.0 require a non-null matched_passage_id.

claims[].match_rationale

String

Must provide a brief explanation of the match or non-match. If matched, must quote the specific supporting text from the trace span. If unmatched, must state 'No supporting evidence found in trace.'

unmatched_claims_summary

Object

Must contain 'count' (integer) and 'severity' (string). 'severity' must be one of: 'none', 'minor', 'major', 'critical'.

trace_id

String

Must exactly match the [TRACE_ID] provided in the prompt input. Used for downstream trace correlation and must not be fabricated.

PRACTICAL GUARDRAILS

Common Failure Modes

Claim extraction and evidence matching traces fail in predictable ways. These are the most common failure modes and the guardrails that catch them before they corrupt your evaluation dataset.

01

Atomic Claim Fragmentation Failures

What to watch: The model splits compound claims incorrectly, producing fragments that are too granular to match or too coarse to verify. A single sentence like 'The system reduced latency by 40% and improved throughput' becomes one unverifiable blob or five meaningless word groups. Guardrail: Include few-shot examples of correct atomic decomposition in the prompt. Validate output claim count against a reasonable range for the input length. Flag outputs with claims shorter than 5 words or longer than 40 words for human review.

02

False Evidence Matches from Semantic Similarity

What to watch: The model matches a claim to a retrieved passage that is semantically adjacent but does not actually support the claim. For example, matching 'the API returns 200 on success' to a passage about HTTP status codes in general, not the specific API behavior. This inflates grounding scores and hides real hallucinations. Guardrail: Require the prompt to output a specific match confidence score with explicit reasoning. Set a minimum confidence threshold (e.g., 0.7) below which matches are flagged for human review. Cross-validate by asking a second pass to identify the strongest counter-evidence passage.

03

Trace Span Pointer Drift

What to watch: The model references trace span IDs or document indices that do not exist in the actual trace, or points to the wrong span after context window truncation shifts positions. This makes the mapping table unusable for downstream debugging. Guardrail: Post-process the output to validate every span pointer against the actual trace event list. Reject or flag any pointer that does not resolve. Include the full span ID list in the prompt context and instruct the model to copy IDs exactly, never to generate or guess them.

04

Implicit Claim Blind Spots

What to watch: The model extracts only explicitly stated claims and misses claims that are implied by the generated answer. An answer stating 'We recommend upgrading to version 2.4' implicitly claims that version 2.4 exists, is stable, and is an upgrade path—but the extraction prompt may skip these if not instructed to capture implications. Guardrail: Add explicit instruction to extract both explicit and implicit factual claims. Include few-shot examples showing implicit claim extraction. Run a second verification pass that asks: 'What must be true for this answer to be correct?' and compare against the extracted claim set.

05

Confidence Score Inflation

What to watch: The model assigns high confidence scores to weak or irrelevant matches because it defaults to optimistic scoring when uncertain. A claim matched to a tangentially related passage receives a 0.85 confidence score, masking a real grounding failure. Guardrail: Anchor confidence scoring with a detailed rubric in the prompt: define what 0.9, 0.7, 0.5, and 0.3 mean in terms of evidence quality. Require the model to state what specific information is missing before assigning scores above 0.7. Calibrate against a small set of human-labeled examples and adjust the prompt if scores drift.

06

Cross-Turn Contamination in Multi-Turn Traces

What to watch: When processing multi-turn conversation traces, the model matches a claim from turn 3 against evidence retrieved in turn 1, ignoring that the context window may have shifted or the user corrected themselves in turn 2. This produces false-positive grounding matches. Guardrail: Include turn boundary markers in the trace input and instruct the model to match claims only against evidence retrieved in the same turn or explicitly carried forward. Add a 'temporal relevance' check that flags matches where the evidence timestamp or turn index predates the claim by more than one turn.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the quality of the claim-evidence mapping table produced by the prompt. Each criterion targets a specific failure mode common in hallucination and grounding analysis.

CriterionPass StandardFailure SignalTest Method

Atomic Claim Extraction

Every sentence in [GENERATED_ANSWER] is decomposed into the smallest independent factual claims. No compound claims remain.

Two distinct facts are fused into a single claim row, or a subjective opinion is listed as a factual claim.

Parse the output JSON. For each claim in the claims array, verify it contains exactly one verifiable factual assertion by manual spot-check on a 10% sample.

Evidence Match Completeness

Every extracted claim has a corresponding entry in the matched_passage field or is explicitly marked as match_status: UNSUPPORTED.

A claim row has a null or missing matched_passage field but is not flagged as UNSUPPORTED in match_status.

Validate the output schema. Assert that for every item in claims, the field match_status is not null and is UNSUPPORTED if matched_passage is null.

Trace Span Pointer Validity

Every matched_passage includes a trace_span_id that corresponds to a real span_id in the provided [TRACE_JSON].

A trace_span_id is a hallucinated UUID, references a non-retrieval span (e.g., a llm_call span), or is missing.

Write a script to extract all trace_span_id values from the output and assert each exists in the span_id field of a retrieval event within [TRACE_JSON].

Match Confidence Calibration

match_confidence scores are consistent with the semantic overlap. A score of HIGH requires near-verbatim support. LOW indicates only tangential relevance.

A match_confidence: HIGH is assigned to a passage that merely shares a keyword but contradicts the claim, or a direct quote is scored as LOW.

For a sample of 10 HIGH confidence matches, manually verify the passage directly entails the claim. For 10 LOW matches, verify the passage does not directly support the claim.

Source Conflict Flagging

If multiple retrieved passages in the trace support contradictory claims, the output includes a source_conflict: true flag and lists the conflicting trace_span_ids.

The output presents a single source as definitive when the [TRACE_JSON] contains another passage with a conflicting fact, and source_conflict is false.

Inject a synthetic conflicting document into a test trace. Assert that the output for the relevant claim has source_conflict: true and the conflicting_span_ids array is populated.

Abstention on Non-Factual Content

Subjective opinions, greetings, and stylistic statements in [GENERATED_ANSWER] are classified with claim_type: NON_FACTUAL and have match_status: NOT_APPLICABLE.

A salutation like 'I hope this helps!' is extracted as a claim and forced into a spurious LOW confidence match with a random passage.

Include a non-factual sentence in a test [GENERATED_ANSWER]. Assert the output classifies it as claim_type: NON_FACTUAL and match_status: NOT_APPLICABLE.

Output Schema Adherence

The output is strictly valid JSON matching the [OUTPUT_SCHEMA] with no extra keys or markdown fences.

The model wraps the JSON in a markdown code block, adds a conversational preamble, or omits the required trace_analysis_id field.

Validate the raw output string with a JSON parser. Assert it passes structural schema validation against [OUTPUT_SCHEMA] and contains no top-level keys beyond those defined.

Truncation Awareness

If a passage in the trace is truncated (e.g., truncated: true in the span metadata), the match_confidence is downgraded to LOW with a truncation_note.

A match_confidence: HIGH is assigned based on a partial match with a truncated passage, ignoring the truncation flag.

Use a test trace where a key passage is explicitly truncated. Assert that any claim matched to this span has match_confidence: LOW and the truncation_note field is populated.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt\nUse the base prompt with a single trace and lighter validation. Replace strict JSON schema enforcement with a markdown table output for faster iteration. Drop the `match_confidence` numeric score in favor of `HIGH`/`MEDIUM`/`LOW` labels.\n\n**Prompt snippet change:**\n`Return a markdown table with columns: claim_id, claim_text, matched_passage_id, match_status (SUPPORTED|PARTIALLY_SUPPORTED|UNSUPPORTED), match_confidence (HIGH|MEDIUM|LOW), trace_span_id, notes.`\n\n### Watch for\n- Missing schema checks letting malformed rows through\n- Overly broad claim splitting that creates unverifiable fragments\n- No deduplication of near-identical claims\n- Match confidence labels drifting in meaning across runs

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.