Inferensys

Prompt

Source Grounding Score Prompt for LLM Outputs

A practical prompt playbook for using Source Grounding Score Prompt for LLM Outputs in production AI workflows.
DevOps engineer deploying LLM to production on laptop, Kubernetes dashboards visible, late night deployment session.
PROMPT PLAYBOOK

When to Use This Prompt

Define when the Source Grounding Score Prompt is the right tool for evaluating LLM outputs and when it will fail.

This prompt is designed for evaluation harnesses and CI/CD pipelines that need a numeric, reproducible score for how well every sentence in a generated text is anchored to provided source documents. The primary job-to-be-done is automated quality gating: before an LLM-generated answer, summary, or report reaches a user or a downstream system, you run this prompt to verify that claims are not hallucinated. The ideal user is an AI engineer or ML ops lead building a RAG system, a document Q&A product, or a compliance-sensitive text-generation pipeline where unsupported statements carry regulatory, financial, or reputational risk. You need the full set of source documents that were available to the generation model, the generated text itself, and a defined grounding rubric.

Do not use this prompt when you lack the original source documents or when the generated text is creative, speculative, or opinion-based by design. This prompt measures factual grounding against provided evidence; it cannot assess whether the sources themselves are correct, complete, or authoritative. It is also a poor fit for real-time chat moderation where latency constraints preclude a full evaluation pass. For high-risk domains such as healthcare, legal, or finance, treat the grounding score as a necessary but not sufficient check—always pair it with human review for outputs that fall below your calibrated threshold. The prompt works best as a gate in a batch evaluation pipeline, not as a synchronous user-facing validator.

What you need before using this prompt: (1) The generated text to evaluate, split into individual sentences or atomic claims. (2) The complete set of source documents or chunks that were provided to the generation model. (3) A grounding rubric defining what counts as 'fully grounded,' 'partially grounded,' and 'not grounded.' (4) A calibration set of human-annotated grounding judgments to validate that the prompt's scores align with your risk tolerance. Next step: After reading this playbook, copy the prompt template, adapt the rubric to your domain, run it against a calibration set of 50-100 examples, and tune the per-sentence and aggregate thresholds before wiring it into your production evaluation harness.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Source Grounding Score Prompt delivers reliable value and where it introduces operational risk. Use these cards to decide if this prompt fits your evaluation pipeline before integrating it into production.

01

Good Fit: RAG Output Validation Pipelines

Use when: you need an automated, numeric score for how well each sentence in a generated answer is anchored to retrieved source chunks. Guardrail: Pair this prompt with a citation completeness gate so that low grounding scores automatically block the output or route it for human review.

02

Bad Fit: Creative or Open-Domain Generation

Avoid when: the model is expected to synthesize, brainstorm, or generate novel content not strictly derived from provided sources. Risk: The prompt will penalize legitimate creative output as ungrounded, producing misleadingly low scores. Guardrail: Use a different eval rubric for creative tasks.

03

Required Input: Sentence-Segmented Output and Source Chunks

Risk: Without pre-segmented sentences and clearly delimited source chunks, the model cannot produce reliable per-sentence grounding scores. Guardrail: Implement a sentence splitter and source chunker upstream. Validate that every sentence and source chunk has a stable identifier before calling this prompt.

04

Operational Risk: Score Drift Across Model Versions

Risk: Grounding score distributions can shift when the underlying model is updated, breaking calibrated thresholds. Guardrail: Maintain a golden dataset of human-annotated grounding judgments. Run regression tests against this dataset after every model upgrade and recalibrate pass/fail thresholds.

05

Operational Risk: Overconfidence on Near-Match Evidence

Risk: The model may assign high grounding scores to sentences that are semantically adjacent to a source but not actually supported by it. Guardrail: Include calibration tests with adversarial near-miss examples in your eval suite. Flag sentences with high scores but low token overlap for human spot-checking.

06

Bad Fit: Real-Time Streaming Outputs

Avoid when: you need grounding scores on streaming tokens before the full response is complete. Risk: Per-sentence scoring requires complete sentences. Partial or mid-stream evaluation produces unreliable results. Guardrail: Run this prompt as a post-generation validation step, not inline during streaming.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for scoring how well each sentence in an LLM-generated text is anchored to provided source documents.

This prompt template is the core of the Source Grounding Score evaluation harness. It instructs the model to act as a strict evaluator, comparing a generated text against a set of source documents sentence by sentence. The output is a structured JSON object containing per-sentence grounding scores, a rationale for each score, and an aggregate document-level score. The template uses square-bracket placeholders for all dynamic inputs, making it ready to be wired into an automated evaluation pipeline where the generated text and its source context are injected programmatically.

text
You are a strict evaluator of factual grounding. Your task is to compare a generated text against a set of provided source documents and assign a grounding score to every sentence.

## INPUT
**Generated Text:**
[GENERATED_TEXT]

**Source Documents:**
[SOURCE_DOCUMENTS]

## SCORING RUBRIC
For each sentence in the Generated Text, assign a score from 0 to 1 based on how well it is supported by the Source Documents:
- **1.0 (Fully Grounded):** All factual claims in the sentence are directly and unambiguously supported by the sources.
- **0.5 (Partially Grounded):** Some claims are supported, but others are missing, or the support is implicit and requires significant inference.
- **0.0 (Not Grounded):** The sentence contains factual claims with no support in the sources, or it directly contradicts them.

## OUTPUT_SCHEMA
Return a single JSON object with the following structure:
{
  "aggregate_score": <float between 0.0 and 1.0>,
  "sentence_scores": [
    {
      "sentence_index": <integer>,
      "sentence_text": "<exact text of the sentence>",
      "score": <float 0.0, 0.5, or 1.0>,
      "rationale": "<brief explanation of the score, citing the specific source passage or noting its absence>"
    }
  ]
}

## CONSTRAINTS
- Do not modify the Generated Text. Score it exactly as provided.
- The `aggregate_score` must be the mean of all `sentence_scores`.
- If a sentence is purely stylistic, transitional, or a header without factual claims, assign a score of 1.0 and note this in the rationale.
- If the Generated Text is empty, return an empty `sentence_scores` array and an `aggregate_score` of 1.0.

To adapt this template, replace the [GENERATED_TEXT] and [SOURCE_DOCUMENTS] placeholders with your actual data. The [SOURCE_DOCUMENTS] should be a single string containing all retrieved context, clearly delimited by document identifiers. For high-stakes workflows, you can extend the [OUTPUT_SCHEMA] to include a [CONFIDENCE] field for each sentence score, allowing a secondary evaluator or human reviewer to focus on low-confidence judgments. The rubric can also be adapted for domain-specific needs, such as penalizing medical or legal claims that lack a direct quote from the source, by adjusting the score definitions and adding a [RISK_LEVEL] parameter that triggers stricter evaluation criteria.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Source Grounding Score Prompt. Each variable must be populated before the prompt is assembled. Missing or malformed inputs are the most common cause of scoring failures.

PlaceholderPurposeExampleValidation Notes

[GENERATED_TEXT]

The LLM output to be scored for source grounding

The warranty period begins on the delivery date and extends for 12 months thereafter.

Must be non-empty string. Split into sentences before scoring. Max 2000 words for reliable per-sentence analysis.

[SOURCE_DOCUMENTS]

Array of source passages the generated text should be grounded in

[{"id": "doc-1", "text": "Warranty coverage starts at delivery and lasts 12 months."}, {"id": "doc-2", "text": "Extended warranties available for purchase."}]

Must be valid JSON array. Each object requires id and text fields. Empty array triggers abstention scoring. Max 50 sources per call.

[GROUNDING_THRESHOLD]

Minimum score for a sentence to be considered grounded

0.7

Float between 0.0 and 1.0. Default 0.5. Lower values increase false positives. Calibrate against human judgments on 50+ examples before production use.

[SENTENCE_SPLIT_METHOD]

How to segment [GENERATED_TEXT] into scorable units

regex

Accepted values: regex, nltk, spacy, newline. Must match pre-processing pipeline. Mismatch causes boundary errors in per-sentence scores.

[OUTPUT_FORMAT]

Desired structure for the grounding score response

per_sentence

Accepted values: per_sentence, aggregate_only, full_audit. full_audit includes evidence mapping for each sentence. per_sentence is default for eval harnesses.

[CALIBRATION_SAMPLES]

Optional human-scored examples for few-shot calibration

[{"sentence": "Coverage is 12 months.", "score": 0.95, "source_id": "doc-1"}]

Must be valid JSON array. Max 10 samples. Each requires sentence, score, and source_id. Omit for zero-shot scoring. Include when domain terminology differs from general use.

[ABSTENTION_LABEL]

Label applied when no source evidence exists for a sentence

UNSUPPORTED

String. Default UNSUPPORTED. Must not conflict with valid source IDs. Used in aggregate scoring to distinguish low-confidence grounding from true abstention.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Source Grounding Score prompt into an evaluation harness or CI/CD pipeline.

The Source Grounding Score prompt is designed to operate as a post-generation evaluation step, not as part of the primary generation request. In a production RAG or document Q&A system, you should call this prompt after the main answer is generated and its citations are resolved. The typical wiring pattern is: (1) the system generates an answer with citations, (2) a post-processing step extracts the answer text and the list of source chunks that were provided to the generation model, (3) this prompt is called with the answer and sources as inputs, and (4) the resulting per-sentence and aggregate grounding scores are logged alongside the interaction for monitoring, gating, or human review routing.

Validation and gating are critical because a grounding score alone does not block bad outputs. Implement a threshold gate after scoring: if the aggregate grounding score falls below your defined minimum (e.g., 0.7 for high-risk domains, 0.5 for exploratory use), route the output for human review or suppress it entirely. For per-sentence scores, flag any sentence scoring below 0.3 as a likely hallucination and either remove it or append an [UNVERIFIED] marker before showing it to users. Store the raw scoring output—including the model's reasoning for each sentence—in your observability system so you can debug false positives and false negatives later. Model choice matters: use a capable instruction-following model (GPT-4, Claude 3.5 Sonnet, or equivalent) for the scoring step, even if your generation model is smaller, because scoring requires careful reasoning about entailment and contradiction.

Retry logic should be minimal for this prompt. If the output fails to parse as valid JSON with the expected schema, retry once with a stronger format instruction. If it still fails, log the raw output and escalate—do not silently fall back to a default score. Calibration is an ongoing concern: periodically run a golden set of human-annotated sentence-source pairs through this prompt and compare the model's grounding scores against human judgments. Track drift over time, especially after model version updates. When grounding scores degrade, investigate whether the issue is in the generation step (producing unsupported claims), the retrieval step (returning irrelevant sources), or the scoring step itself (model behavior change). Wire these calibration results into your prompt regression test suite so that a drop in scoring accuracy triggers an alert before it affects users.

PRACTICAL GUARDRAILS

Common Failure Modes

Source grounding scores fail silently in production when models hallucinate citations, inflate confidence, or misinterpret evidence boundaries. These are the most common failure patterns and the guardrails that catch them before they reach users.

01

Hallucinated Citations with High Confidence

What to watch: The model generates a plausible-sounding citation with a page number, section heading, or source reference that does not exist in the provided documents. The grounding score may still report high confidence because the model's internal consistency check passes. Guardrail: Implement a citation-verification step that attempts to retrieve the exact cited span from the source document. If the span cannot be located, flag the citation as unverifiable and reduce the aggregate grounding score. Run this verification before surfacing any citation to users.

02

Overconfident Scores on Vague or Circular Evidence

What to watch: The model assigns a high grounding score to a claim that is only loosely related to the source. This happens when the source text uses similar vocabulary but does not actually support the specific factual assertion. The model conflates topical relevance with evidentiary support. Guardrail: Add a calibration layer that compares grounding scores against human-annotated benchmarks for your domain. Use a separate entailment check prompt that asks whether the source text strictly entails, weakly supports, or contradicts the claim. Downgrade scores when only weak support is found.

03

Evidence Boundary Slicing Across Chunks

What to watch: Supporting evidence is split across two retrieval chunks, and the model only sees one fragment. The grounding score drops or the model fabricates the missing portion rather than flagging incomplete evidence. This is common with table rows, bulleted lists, and sentences that span page breaks. Guardrail: Implement chunk-overlap aware retrieval and include adjacent chunk context in the grounding evaluation prompt. When a claim relies on evidence near chunk boundaries, require the model to check the preceding and following chunks before assigning a score. Flag boundary-adjacent claims for higher scrutiny.

04

Silent Abstention Failures

What to watch: The grounding prompt instructs the model to abstain or return a low score when no evidence exists, but the model instead generates a mid-range score with a generic justification like 'the source implies this.' This creates a false sense of partial support where none exists. Guardrail: Add a pre-check step that asks a binary question: 'Is there any passage in the provided sources that directly addresses this claim?' If the answer is no, bypass the scoring prompt entirely and return a score of zero with an explicit 'no evidence found' flag. Do not rely on the scoring prompt alone to enforce abstention.

05

Score Inflation from Source Repetition

What to watch: The same evidence appears multiple times across retrieved chunks due to document duplication, near-duplicate passages, or overlapping retrieval windows. The model counts each occurrence as independent support, inflating the aggregate grounding score. Guardrail: Deduplicate evidence passages before scoring. Use text similarity thresholds to cluster near-identical spans and treat them as a single piece of evidence. Report both the raw citation count and the deduplicated evidence count in the grounding output so downstream systems can detect inflation.

06

Temporal Drift Between Source and Claim

What to watch: The source document is outdated relative to the claim being evaluated, but the grounding score does not account for temporal relevance. A claim about 'current pricing' may be perfectly grounded in a two-year-old document, producing a high score that is technically correct but practically misleading. Guardrail: Include document date metadata in the grounding evaluation context. Add a temporal relevance check that asks whether the source date is appropriate for the claim's timeframe. Produce a separate temporal-freshness flag alongside the grounding score so consumers can weigh recency independently from textual support.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the quality of source grounding scores produced by the prompt. Each criterion defines a pass standard, a failure signal, and a concrete test method for integration into an automated evaluation harness.

CriterionPass StandardFailure SignalTest Method

Per-Sentence Score Granularity

Every sentence in [GENERATED_TEXT] receives an individual grounding score between 0.0 and 1.0

Missing sentences in the score array or a single aggregate score returned without per-sentence breakdown

Parse output JSON and assert len(scores) equals sentence count in [GENERATED_TEXT]

Aggregate Score Calculation

Aggregate grounding score is the arithmetic mean of all per-sentence scores, rounded to 2 decimal places

Aggregate score differs from calculated mean by more than 0.01 or is missing entirely

Compute mean of per-sentence scores and compare to returned aggregate_score field

Direct Quote Anchoring

Sentences containing verbatim text from [SOURCE_DOCUMENTS] receive a score of 0.9 or higher

Verbatim quotes scored below 0.7 or flagged as unsupported

Inject a sentence that is an exact quote from a source and assert score >= 0.9

Unsupported Claim Detection

Sentences with no supporting evidence in any source receive a score of 0.2 or lower

Fabricated claims scored above 0.4 or marked as grounded

Insert a sentence with a fact not present in any source and assert score <= 0.2

Partial Support Scoring

Sentences mixing supported and unsupported clauses receive a score between 0.3 and 0.7

Mixed sentences scored as fully grounded above 0.8 or fully unsupported below 0.2

Provide a sentence where only half the claim is in sources and assert 0.3 <= score <= 0.7

Source Identifier Traceability

Each per-sentence score includes a source_ids array listing which source documents provided evidence

source_ids is null, empty, or contains identifiers not present in [SOURCE_DOCUMENTS]

Validate that every source_id in the output exists in the input source document ID list

Calibration Against Human Judgments

Aggregate grounding score is within 0.15 of a human-annotated reference score on a held-out calibration set of 20 examples

Score deviates from human reference by more than 0.15 on more than 3 of 20 calibration examples

Run prompt on calibration set with known human grounding scores and compute mean absolute error

Empty Source Handling

When [SOURCE_DOCUMENTS] is an empty list, all sentences receive a score of 0.0 and aggregate_score is 0.0

Non-zero scores returned when no sources are provided

Pass an empty source list and assert all per-sentence scores equal 0.0

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single frontier model and manual review of outputs. Start with a simple JSON schema for per-sentence scores and an aggregate grounding score. Run 20-30 examples through the prompt and spot-check whether the scores align with your intuition. Use a small set of [SOURCE_DOCUMENTS] and [GENERATED_TEXT] pairs that represent your typical use case.

Prompt modification

Remove the calibration test section and the strict schema enforcement wrapper. Replace [OUTPUT_SCHEMA] with a simple JSON structure: {"per_sentence_scores": [{"sentence": "...", "grounding_score": 0.0-1.0, "evidence_span": "..."}], "aggregate_score": 0.0-1.0}. Drop the [CALIBRATION_TESTS] placeholder entirely.

Watch for

  • Scores that don't correlate with human judgment
  • Overconfident scores when evidence is thin
  • Missing evidence_span fields when the model can't find a match
  • Inconsistent scoring scale across different 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.