Inferensys

Prompt

Attribution Span Accuracy Trace Review Prompt

A practical prompt playbook for using the Attribution Span Accuracy Trace Review Prompt in production AI workflows to measure and correct fine-grained citation precision and recall.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Define the precise job, the ideal user, the required inputs, and the hard boundaries for the Attribution Span Accuracy Trace Review Prompt.

This prompt is for AI engineers and quality teams who operate fine-grained citation systems where the model must link specific text spans in its output to specific evidence spans in the source material. The job-to-be-done is not just checking if a citation exists, but verifying that the cited span precisely covers the claim—no more, no less. Over-citation erodes user trust by claiming support for statements the source never made; under-citation leaves supported claims looking like unsourced speculation. Use this prompt when you have a production trace that includes the generated output with its attribution spans and the full retrieved source documents, and you need a rigorous, span-level precision and recall audit.

The ideal user is a developer or quality engineer who has already instrumented their RAG pipeline to capture attribution metadata in traces. You must have access to the raw trace data: the final generated text, the array of attribution spans (each with start/end character offsets and a source document pointer), and the complete content of each cited source document. Without this granular trace data, the prompt cannot perform span-level alignment. Do not use this prompt for high-level fact-checking or binary hallucination detection—those are different jobs covered by sibling playbooks like the RAG Citation Verification Trace Prompt or the Unsupported Claim Detection Prompt. This prompt is specifically for systems where the model itself is expected to output inline citations with character-level precision.

This prompt is not a replacement for automated span-matching algorithms or deterministic string comparison. It is a diagnostic tool for cases where semantic alignment matters: when a claim is supported by a source but the model cited the wrong sentence, or when the model cited a whole paragraph for a single fact. It is also not suitable for real-time guardrails due to the latency of LLM-based review. Use it for offline trace audits, regression test suites, and periodic quality reviews. If your system does not produce attribution spans, start with a broader hallucination trace analysis prompt instead. Before running this prompt, ensure your traces are complete and your source documents are accessible—missing context will produce unreliable precision/recall scores.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Use these cards to decide if the Attribution Span Accuracy Trace Review Prompt is the right tool for your trace analysis workflow.

01

Good Fit: Fine-Grained Citation Systems

Use when: your RAG system generates inline attribution spans (e.g., sentence-level or phrase-level citations) and you need to verify that each span precisely covers the claim it cites. Guardrail: ensure traces capture both the generated output with span markers and the retrieved source document offsets before running this prompt.

02

Good Fit: Span-Level Precision and Recall Audits

Use when: you need quantitative span-level metrics (precision, recall, boundary F1) rather than binary citation-correctness judgments. Guardrail: define your span overlap threshold (exact match, partial overlap, or IoU) in the prompt's [CONSTRAINTS] to avoid metric ambiguity across review runs.

03

Bad Fit: Coarse Citation Without Spans

Avoid when: your system only provides document-level or passage-level citations without character-offset or token-offset span annotations. This prompt requires span boundaries to compute precision and recall. Guardrail: use the RAG Citation Verification Trace Prompt instead for document-level citation checks.

04

Bad Fit: Real-Time Production Guarding

Avoid when: you need sub-second latency for production request-time citation validation. This prompt is designed for offline trace review and batch analysis. Guardrail: implement a lightweight span-overlap validator in application code for real-time checks, and reserve this prompt for daily or weekly trace audits.

05

Required Inputs: Span-Annotated Traces

Risk: running this prompt without span-offset metadata in your traces will produce meaningless results. Guardrail: confirm your trace schema includes generated_spans (with start/end offsets and cited claim text) and source_spans (with document offsets and passage text) before invoking this prompt. Missing offsets should trigger an input validation failure.

06

Operational Risk: Over-Claiming and Under-Claiming Drift

Risk: models may gradually expand citation spans to cover adjacent unsupported content (over-claiming) or shrink spans to avoid accountability (under-claiming), and this drift is invisible without span-level review. Guardrail: run this prompt on a stratified sample of traces weekly and track span precision/recall trends on a dashboard. Set alert thresholds when precision drops below 0.85 or recall drops below 0.80.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for verifying that attribution spans in a generated output precisely cover the claims they cite, using trace data.

This prompt template is designed to be copied directly into your AI harness for fine-grained citation review. It instructs the model to act as a forensic auditor, comparing the generated output against the retrieved source documents captured in a production trace. The core task is to evaluate every attribution span—the specific text segment linked to a citation—and determine if it accurately, completely, and exclusively represents the source material. The output is a structured report with span-level precision and recall metrics, making it suitable for automated evaluation pipelines or human-in-the-loop quality assurance workflows.

markdown
You are an expert forensic auditor evaluating the precision of inline citations in AI-generated text. Your task is to compare the [GENERATED_OUTPUT] against the [RETRIEVED_SOURCES] provided in the trace to verify the accuracy of every attribution span.

An attribution span is a segment of text in the [GENERATED_OUTPUT] that is directly linked to a specific source ID via a citation marker (e.g., `[1]`). For each span, you must determine if it is:
- **Precise**: The span's claim is fully and directly supported by the cited source text. No more, no less.
- **Over-claiming**: The span makes a claim that is broader, stronger, or more specific than what the source text supports.
- **Under-claiming**: The span omits a critical part of the claim that *is* supported by the source, making the citation misleadingly narrow.
- **Unsupported**: The span's claim cannot be found in or reasonably inferred from the cited source text.

# INPUT DATA

## Generated Output with Attribution Spans
```json
[GENERATED_OUTPUT]

Retrieved Sources from Trace

json
[RETRIEVED_SOURCES]

OUTPUT SCHEMA

Return a single JSON object conforming to this schema:

json
{
  "spans": [
    {
      "span_id": "string (unique identifier for the span)",
      "span_text": "string (the exact text of the attribution span)",
      "cited_source_id": "string (the ID of the source it cites)",
      "status": "precise | over-claiming | under-claiming | unsupported",
      "explanation": "string (a concise, evidence-based justification for the status, quoting the source text)",
      "correction": "string | null (if not precise, provide a corrected span text that would be precise)"
    }
  ],
  "aggregate_metrics": {
    "total_spans": "number",
    "precise_count": "number",
    "over_claiming_count": "number",
    "under_claiming_count": "number",
    "unsupported_count": "number",
    "span_precision": "number (precise_count / total_spans)",
    "span_accuracy": "number ((precise_count) / (total_spans - unsupported_count))"
  },
  "trace_event_references": [
    {
      "span_id": "string",
      "trace_event_id": "string (the ID of the retrieval or generation event in the trace where this span was created)"
    }
  ]
}

CONSTRAINTS

  • [CONSTRAINTS]
  • If no attribution spans are present in the [GENERATED_OUTPUT], return an empty spans array and set all metrics to 0.
  • Your explanation must quote the specific sentence or phrase from the source that supports or contradicts the span.
  • Do not invent source content. If the source is ambiguous, mark the span as unsupported and explain the ambiguity.

To adapt this template for your system, replace the square-bracket placeholders with your actual data structures. The [GENERATED_OUTPUT] should be the final text with citation markers, and [RETRIEVED_SOURCES] should be a JSON object mapping source IDs to their full text as captured in the trace. The [CONSTRAINTS] placeholder is critical for high-risk domains; for example, in a healthcare setting, you might add: If a span makes a clinical claim, and the source only states a correlation, mark it as over-claiming. After running this prompt, always validate the output JSON against the schema before ingesting it into your monitoring dashboard. For production systems, log any parse failures and trigger a retry with a simpler, more explicit output format instruction.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Attribution Span Accuracy Trace Review Prompt. Each placeholder must be populated from production trace data before the prompt is executed. Missing or malformed inputs will cause span-level precision and recall metrics to be unreliable.

PlaceholderPurposeExampleValidation Notes

[GENERATED_OUTPUT]

The full model-generated text containing inline attribution spans to be reviewed

According to [1] the API latency improved by 40% while [2] notes that throughput remained stable.

Must be non-empty string. Parse check: verify that span markers like [1] or [source_3] are present. If no spans found, return error: 'No attribution spans detected in output.'

[ATTRIBUTION_SPANS]

Array of span objects mapping each citation marker to its character offsets in the generated output

[{"marker": "[1]", "start": 14, "end": 53, "claim_text": "the API latency improved by 40%"}]

Must be valid JSON array. Schema check: each span requires marker, start, end, and claim_text fields. start must be less than end. claim_text must match substring at offsets. If empty array, prompt should return span recall of 0.

[RETRIEVED_SOURCES]

Array of source documents retrieved during the RAG step, each with a source ID and full text

[{"source_id": "1", "text": "API latency decreased from 200ms to 120ms, a 40% improvement."}]

Must be valid JSON array. Each source requires source_id and text fields. text must be non-empty. Source IDs must match the markers used in attribution spans. If a marker references a missing source_id, flag as citation-to-source alignment failure.

[TRACE_ID]

Unique identifier for the production trace being reviewed, used for anchoring findings to observability systems

trace_2025-03-15_14-22-07_a1b2c3

Must be non-empty string. Used for trace-anchored corrections in output. If null or missing, prompt should still execute but flag that findings cannot be linked to trace storage.

[SESSION_METADATA]

Optional metadata about the request context including model version, prompt version, and retrieval configuration

{"model": "claude-3.5-sonnet", "prompt_version": "v2.4.1", "retrieval_top_k": 5}

Null allowed. If provided, must be valid JSON object. Use to contextualize span accuracy findings. If model version present, include in output for version-to-version comparison.

[PRECISION_THRESHOLD]

Minimum acceptable span-level precision score before flagging output for human review

0.85

Must be a float between 0.0 and 1.0. Default to 0.80 if not specified. Used to determine pass/fail in output. If set below 0.5, emit warning that threshold may allow low-quality attributions.

[RECALL_THRESHOLD]

Minimum acceptable span-level recall score before flagging under-attribution

0.90

Must be a float between 0.0 and 1.0. Default to 0.85 if not specified. Recall below threshold indicates claims present without citations. If set to 1.0, expect near-certain false positives on borderline cases.

[PREVIOUS_CORRECTIONS]

Array of prior human corrections for this trace or similar spans, used for few-shot calibration

[{"span_marker": "[1]", "correction": "over-claiming", "note": "Source only supports latency improvement, not the 40% figure"}]

Null allowed. If provided, must be valid JSON array. Each correction requires span_marker and correction fields. Use to improve consistency with prior human judgments. If empty, prompt runs without calibration context.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Attribution Span Accuracy Trace Review Prompt into an automated evaluation pipeline or manual QA workflow.

This prompt is designed to be a programmatic evaluation step, not a one-off chat interaction. It expects a structured trace object containing the generated output, the list of attribution spans, and the full retrieved context for each cited source. The primary integration point is within a CI/CD pipeline for prompt releases, a scheduled batch evaluation job, or a human-in-the-loop QA tool where a reviewer can inspect flagged spans. The prompt's output—a JSON object with span-level precision and recall metrics—is intended to be consumed by a monitoring dashboard or an alerting system, not just read by a human.

To wire this into an application, construct the [TRACE_INPUT] by serializing the relevant fields from your tracing system (e.g., LangSmith, Arize, or a custom log). The input must include: the generated_text, an array of attribution_spans (each with span_id, text, and cited_source_id), and a map of retrieved_sources keyed by source_id with their full text. Before calling the model, validate the input shape against a strict schema (e.g., using Pydantic or JSON Schema) to prevent malformed requests. After receiving the model's output, validate the JSON structure and check for the span_evaluations array. Implement a retry loop with a maximum of 2 attempts if the output fails to parse or is missing required fields. Log every raw request and response pair, along with the parsed metrics, to your observability platform for later analysis.

For high-stakes applications, do not treat the model's precision/recall scores as ground truth without verification. Implement a calibration step where a random sample of span evaluations is reviewed by a human, and the model's agreement rate with the human is tracked over time. If the agreement rate drops below a threshold (e.g., 90%), pause automated gating and escalate for prompt or model review. Use a capable model with strong instruction-following and JSON mode (such as GPT-4o or Claude 3.5 Sonnet) for this task; smaller or older models often struggle with the precise text-boundary matching required for span-level attribution. Finally, feed the per-span precision and recall metrics into your evaluation dashboard, setting alerts for any regression below a predefined threshold (e.g., precision < 0.95) to catch citation quality degradation before it reaches users.

PRACTICAL GUARDRAILS

Common Failure Modes

Attribution span systems fail in predictable ways. These cards cover the most common failure modes when verifying that citations precisely cover their claims, along with concrete guardrails to catch each issue before it reaches production.

01

Over-Claiming Source Support

What to watch: The model extends an attribution span beyond what the source actually supports, citing a document for a claim it doesn't make. This inflates precision metrics and misleads users into trusting unsupported statements. Guardrail: Implement span-level verification that extracts the exact text within each attribution boundary and runs pairwise entailment against the cited source passage. Flag spans where entailment confidence falls below 0.8 for human review.

02

Under-Claiming and Missing Citations

What to watch: The model fails to attach a citation to a factual claim that is actually supported by a retrieved source. This deflates recall and makes the output appear less grounded than it is, eroding user trust. Guardrail: Run a claim extraction pass over the full output first, then check each atomic claim against all retrieved sources. Any supported claim without a span gets flagged as a missed citation opportunity with the matching source ID.

03

Span Boundary Misalignment

What to watch: The citation span covers the right source but the wrong text range—either including adjacent unsupported sentences or cutting off mid-claim. This produces noisy training data for eval pipelines and confuses downstream consumers. Guardrail: Apply a span tightening heuristic that trims attribution boundaries to the minimal text range that still contains the supported claim. Compare original and tightened spans and flag deltas exceeding 20 characters for manual adjustment.

04

Multi-Source Confusion in Single Span

What to watch: A single attribution span cites one source but the claim within that span actually synthesizes information from multiple retrieved documents. The span-level precision metric looks correct but the grounding is incomplete. Guardrail: Decompose each attributed span into atomic sub-claims and verify each sub-claim independently against the cited source. If a sub-claim requires a different source, flag the span as requiring multi-source attribution or claim splitting.

05

Hallucinated Source References

What to watch: The model generates a citation to a source ID or document title that doesn't exist in the retrieval trace. This is a critical failure mode in fine-grained citation systems where the model fabricates convincing but nonexistent references. Guardrail: Cross-reference every citation target in the output against the actual retrieved document IDs in the trace event log. Reject any citation that doesn't resolve to a real trace event and escalate to a human reviewer with the full trace context.

06

Context Window Truncation Masking Gaps

What to watch: Retrieved passages that were truncated due to context window limits appear absent from the trace, making it impossible to verify whether a claim was actually supported. The attribution system may mark claims as unsupported when the evidence existed but was cut. Guardrail: Check trace metadata for truncation events on each retrieved document. When truncation is detected, flag all claims that might relate to the truncated portion as indeterminate rather than unsupported, and log a context budget warning for the retrieval pipeline.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the quality of the Attribution Span Accuracy Trace Review Prompt's output before integrating it into a production monitoring pipeline. Each criterion should be tested against a curated set of 10-20 production traces with known attribution errors.

CriterionPass StandardFailure SignalTest Method

Span Precision

All predicted attribution spans are fully contained within a single source passage that directly supports the claim.

A predicted span overlaps with an unsupportive passage, extends beyond the supporting evidence, or is placed on a non-factual statement.

Run on 20 traces with human-annotated spans. Precision must be >= 0.95. A failure is any false positive span.

Span Recall

Every factual claim in the output that requires a citation has at least one correctly predicted attribution span.

A factual claim is present in the output but has no overlapping predicted span, or the predicted span is on the wrong source passage.

Run on 20 traces with human-annotated claims. Recall must be >= 0.90. A failure is any missed claim that requires a citation.

Over-Claiming Detection

The output explicitly flags any predicted span where the source passage does not fully justify the claim's scope or certainty.

A claim is marked as 'supported' when the source only provides partial, tangential, or weaker evidence than the claim asserts.

Inject 5 traces with known over-claims. The prompt output must correctly flag all 5. A failure is any unflagged over-claim.

Under-Claiming Detection

The output identifies when a claim is more weakly stated than the source evidence supports, indicating a missed opportunity for a stronger citation.

A strong, definitive source passage is cited for a hedged or non-committal claim without noting the discrepancy.

Inject 5 traces with known under-claims. The prompt output must identify at least 4. A failure is missing more than 1 under-claim.

Trace Event Anchoring

Every correction or metric in the output is linked to a specific trace_event_id for the source passage and the generated claim.

A correction is described without a reference to the specific trace event, making it impossible to locate the error in the trace.

Parse the output JSON. The trace_event_id field must be non-null and match an ID in the input trace for every item in the span_corrections array.

Metric Calculation Accuracy

The calculated span_precision and span_recall scores in the output match a ground-truth calculation based on the provided corrections.

The reported precision/recall scores are inconsistent with the list of true/false positives and false negatives detailed in the output.

For 10 traces, manually calculate precision and recall from the output's own list of corrections. The reported score must match the manual calculation exactly.

Output Schema Validity

The output is valid JSON that strictly conforms to the [OUTPUT_SCHEMA] with all required fields present and correctly typed.

The output is not valid JSON, is missing a required field like span_corrections, or contains a field with an incorrect data type (e.g., a string instead of a float).

Validate the output against the [OUTPUT_SCHEMA] using a JSON schema validator. The test fails if validation errors are returned.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single trace and manual review. Remove strict schema requirements and focus on getting a readable span-level analysis. Replace [OUTPUT_SCHEMA] with a simple markdown table request.

Watch for

  • The model may describe spans qualitatively instead of computing precision/recall
  • Overly broad instructions can produce verbose prose instead of actionable corrections
  • Without schema enforcement, span offsets may be inconsistent 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.