Inferensys

Prompt

Reference-Based Evaluation Prompt Template

A practical prompt playbook for using Reference-Based Evaluation Prompt Template in production AI workflows to compare outputs against golden references with semantic equivalence detection and partial-credit rules.
Stylish home-office setup in a modern highrise apartment, floor-to-ceiling windows showing city skyline at golden hour, a laptop displaying a beautiful semantic search interface.
PROMPT PLAYBOOK

When to Use This Prompt

Identify the right evaluation scenarios for the Reference-Based Evaluation Prompt Template and understand its operational boundaries.

This prompt is for AI quality engineers and platform teams who need to compare a generated output against a known golden reference. It produces a similarity score with semantic equivalence detection, acceptable variation boundaries, and exact-match versus paraphrase differentiation. Use this when you have a curated golden dataset and need automated, repeatable evaluation that goes beyond string matching. This prompt belongs in regression test suites, CI/CD eval gates, and any workflow where you must quantify how closely a new prompt version reproduces expected behavior.

The ideal user has already built a golden dataset of input-output pairs that represent correct, expected behavior. You should wire this prompt into an automated harness that iterates over test cases, calls the prompt for each pair, and aggregates the similarity scores into a pass/fail report. The prompt handles both exact-match verification and semantic equivalence, which means it can distinguish between a permissible paraphrase ('The user's balance is $42.50') and an unacceptable deviation ('The balance appears sufficient'). Configure the acceptable variation boundaries in the [CONSTRAINTS] placeholder to match your domain's tolerance. For high-stakes domains like healthcare or finance, set strict boundaries and always include a human review step for borderline scores.

Do not use this prompt for open-ended generation tasks where no reference exists; use the Reference-Free Evaluation Prompt Template instead. Do not use this for pairwise A/B comparisons; use the Pairwise Comparison Judge Prompt Template. Avoid this prompt when your golden dataset is small or unrepresentative, as the scores will give false confidence. If you observe score inflation over time, audit your golden dataset for memorization leakage or drift. The next section provides the copy-ready template you can adapt and integrate into your eval harness.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Reference-Based Evaluation Prompt Template delivers reliable signal and where it introduces risk. Use these cards to decide if this eval pattern fits your QA workflow.

01

Good Fit: Deterministic Outputs with Canonical Answers

Use when: your task has a single correct answer or a narrow acceptable range, such as code generation, data extraction, or math problem solving. Guardrail: define exact-match and semantic-equivalence thresholds before running evals, and document which variations are acceptable.

02

Bad Fit: Open-Ended Creative Generation

Avoid when: evaluating poetry, marketing copy, or brainstorming outputs where quality is subjective and multiple valid answers exist. Guardrail: switch to a rubric-based or pairwise comparison judge for these tasks, and reserve reference-based evals for factual or structural correctness checks.

03

Required Inputs: Golden References and Acceptable Variation Rules

Risk: without a high-quality reference dataset and explicit variation boundaries, the eval produces misleading scores. Guardrail: invest in curating golden outputs, document which fields allow paraphrasing vs. require exact match, and version your reference set alongside your prompts.

04

Operational Risk: Reference Drift Over Time

Risk: golden references become stale as product requirements, schemas, or domain facts change, causing false regressions. Guardrail: schedule periodic reference-set reviews, track reference version in eval metadata, and flag references older than your change cadence for refresh.

05

Operational Risk: Semantic Equivalence Blind Spots

Risk: the eval may penalize correct outputs that use different phrasing, ordering, or formatting than the reference. Guardrail: implement partial-credit rules for semantic equivalence, use an LLM judge to verify equivalence before scoring, and log borderline cases for human review.

06

Bad Fit: High-Stakes Decisions Without Human Review

Avoid when: the eval score directly gates production deployments in regulated domains without human oversight. Guardrail: add a human review step for borderline or failing cases, set confidence thresholds that trigger escalation, and never treat automated similarity scores as sole acceptance criteria.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for comparing an AI-generated output against a golden reference, producing a structured similarity score with semantic equivalence detection and partial-credit rules.

This template is the core instruction set you will send to an LLM judge. It is designed to be wired into an automated evaluation harness where the [CANDIDATE_OUTPUT] is the text your system produced and the [REFERENCE_OUTPUT] is the known-good, human-validated answer. The prompt forces the model to act as a strict evaluator, distinguishing between exact matches, acceptable paraphrases, and substantive errors, rather than giving a vague 'looks good' rating.

text
You are an expert output evaluator. Your task is to compare the [CANDIDATE_OUTPUT] against the [REFERENCE_OUTPUT] and produce a structured similarity assessment.

## Evaluation Criteria
1. **Exact Match**: The candidate is character-for-character identical to the reference, ignoring leading/trailing whitespace.
2. **Semantic Equivalence**: The candidate conveys the same core facts, intent, and meaning as the reference, even if wording, structure, or examples differ. This is a pass.
3. **Acceptable Variation**: The candidate adds minor, non-contradictory details or omits non-essential context without changing the core answer. This is a partial pass.
4. **Substantive Difference**: The candidate contradicts a fact in the reference, introduces a hallucination, changes a key decision, or omits a critical constraint. This is a fail.

## Constraints
- [CONSTRAINTS]

## Output Schema
Respond ONLY with a valid JSON object matching this schema:
{
  "similarity_score": <float 0.0-1.0>,
  "equivalence_class": "exact_match" | "semantic_equivalent" | "acceptable_variation" | "substantive_difference",
  "partial_credit": <float 0.0-1.0>,
  "rationale": "<concise explanation of the judgment>",
  "key_differences": ["<list of specific divergences>"]
}

## Partial Credit Rules
- exact_match: partial_credit = 1.0
- semantic_equivalent: partial_credit = 0.95
- acceptable_variation: partial_credit = 0.7
- substantive_difference: partial_credit = max(0.0, 1.0 - (number_of_critical_errors * 0.3))

## Inputs
[CANDIDATE_OUTPUT]:
"""
[CANDIDATE_OUTPUT]
"""

[REFERENCE_OUTPUT]:
"""
[REFERENCE_OUTPUT]
"""

## Examples
[EXAMPLES]

To adapt this template, start by populating the [CONSTRAINTS] placeholder with domain-specific rules, such as 'Ignore differences in markdown formatting' or 'A change in a numerical value is always a substantive difference.' The [EXAMPLES] placeholder should contain 2-3 few-shot demonstrations showing borderline cases, like a paraphrase that should be scored as semantic_equivalent versus one that drifts into acceptable_variation. If you are evaluating in a high-risk domain like healthcare or finance, add a constraint requiring the rationale to cite specific evidence from the reference, and always route substantive_difference results to a human review queue before accepting the score as final. Do not deploy this prompt without first running it against a calibration set of 20-30 known pairs to verify that the judge's similarity_score and equivalence_class assignments align with your team's expectations.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the reference-based evaluation prompt. Each variable must be populated before the prompt is assembled and sent to the model. Missing or malformed inputs are the most common cause of eval harness failures.

PlaceholderPurposeExampleValidation Notes

[CANDIDATE_OUTPUT]

The generated text being evaluated against the reference

The capital of France is Paris, a city known for its cultural landmarks.

Must be non-empty string. Truncate if longer than model context window minus prompt overhead. Check for encoding issues if copy-pasted from logs.

[REFERENCE_OUTPUT]

The ground-truth or gold-standard answer to compare against

Paris is the capital of France.

Must be non-empty string. Verify source provenance before use. Multiple reference variants can be concatenated with delimiters if acceptable answers differ in phrasing.

[EVAL_CRITERIA]

The specific dimensions to score: semantic equivalence, factual overlap, completeness, conciseness

semantic_equivalence, factual_accuracy, no_hallucination

Must be a comma-separated list drawn from a controlled vocabulary. Reject unknown criteria names. At least one criterion required.

[PARTIAL_CREDIT_RULES]

Instructions for awarding partial scores when output is mostly correct but incomplete or contains minor extras

Award 0.7 if core facts match but output omits one non-critical detail. Award 0.0 if any hallucinated claim is present.

Must be explicit and testable. Avoid vague rules like 'use judgment.' Test with known partial-match cases before production use.

[SCORE_RANGE]

The numeric range for output scores, typically 0.0 to 1.0 or 1 to 5

0.0 to 1.0 in 0.1 increments

Must define min, max, and granularity. Reject scores outside range. Floating-point tolerance must be specified if using exact-match assertions downstream.

[ACCEPTABLE_VARIATION_BOUNDARY]

Explicit description of what kinds of phrasing differences should NOT reduce the score

Synonym substitution, active/passive voice changes, and reordered clauses are acceptable if factual content is preserved.

Must include concrete linguistic examples. Test with paraphrased reference outputs to verify boundary is neither too strict nor too loose.

[EXACT_MATCH_THRESHOLD]

The score threshold above which outputs are considered functionally identical to the reference

0.95

Must be a float within SCORE_RANGE. Used to separate 'identical meaning' from 'similar meaning.' Calibrate against human judgments on 20+ pairs.

[OUTPUT_FORMAT]

The required structure for the evaluation result: JSON schema, field names, and types

{"score": float, "rationale": string, "hallucinated_claims": string[], "missing_facts": string[]}

Must be a valid JSON Schema or explicit field list. Every downstream parser depends on this. Validate that the model can produce this format reliably before running at scale.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the reference-based evaluation prompt into a reliable, automated QA pipeline.

The reference-based evaluation prompt is not a one-off tool; it is a scoring function that should be embedded into a deterministic application harness. The harness is responsible for orchestrating the model call, validating the structured output, managing retries, and logging every judgment for auditability. Treat this prompt as a microservice with a strict contract: it receives a candidate output and a golden reference, and it must return a machine-readable similarity score with supporting evidence. The harness, not the prompt, enforces timeouts, handles malformed JSON, and decides whether a failing score blocks a release.

Implement the harness with these concrete components. Input validation: before calling the model, assert that both [CANDIDATE_OUTPUT] and [REFERENCE_OUTPUT] are non-empty strings and that any [ACCEPTABLE_VARIATION_RULES] are well-formed. Model selection: use a model with strong instruction-following and JSON mode support (e.g., gpt-4o, claude-3.5-sonnet). Avoid models prone to verbosity or format drift for this task. Structured output enforcement: call the model with response_format: { type: "json_object" } and provide the exact JSON schema from the prompt template. Post-processing: parse the response, validate it against the schema, and extract the similarity_score. If parsing fails, retry once with a repair prompt that includes the raw output and the schema. Retry logic: implement exponential backoff for rate limits (429) and server errors (5xx), but fail fast on persistent validation errors (after 2 retries) to avoid burning budget on a broken prompt. Logging: record the evaluation_id, prompt_version, model_id, candidate_output_hash, reference_output_hash, raw score, parsed justification, and latency for every call. This log becomes your eval audit trail.

For high-stakes workflows—such as gating a production deployment or evaluating safety-critical outputs—add a human review fallback. If the similarity score falls into a configured ambiguity band (e.g., 0.6–0.8), flag the evaluation for manual inspection rather than auto-passing or auto-failing. Do not treat the LLM judge as ground truth; treat it as a calibrated measurement instrument that requires ongoing monitoring. Regularly run the calibration prompt from the sibling playbook against a held-out set of human-labeled pairs to detect judge drift. Finally, integrate the harness into your CI/CD pipeline as a gating step: the deployment script calls the evaluation harness, checks the score against a [PASS_THRESHOLD], and blocks the release if the threshold is not met.

IMPLEMENTATION TABLE

Expected Output Contract

Define the structure and validation rules for the reference-based evaluation output. Use this contract to build automated checks in your eval harness.

Field or ElementType or FormatRequiredValidation Rule

similarity_score

float (0.0 to 1.0)

Must be a number between 0.0 and 1.0 inclusive. Parse check: float. Range check: 0.0 <= score <= 1.0.

semantic_equivalence

boolean

Must be true or false. True only when the candidate output conveys the same meaning as the reference, allowing for paraphrase.

exact_match

boolean

Must be true or false. True only when the candidate output is a character-level match with the reference after normalization (trim whitespace, lowercase).

acceptable_variation

boolean

Must be true or false. True when differences from the reference are within the defined variation boundaries and do not alter core meaning or facts.

partial_credit_breakdown

array of objects

If present, each object must contain 'criterion' (string), 'score' (float 0.0-1.0), and 'justification' (string). Array must not be empty if provided.

variation_notes

string or null

If acceptable_variation is false, this field must contain a non-empty string explaining why. If acceptable_variation is true, this field may be null or a brief summary.

confidence

float (0.0 to 1.0) or null

If provided, must be a float between 0.0 and 1.0. Represents the evaluator's confidence in the similarity_score. Null allowed when confidence cannot be estimated.

evaluation_timestamp

ISO 8601 string

Must be a valid ISO 8601 datetime string in UTC (e.g., 2025-01-15T14:30:00Z). Parse check: datetime. Format check: ISO 8601 with Z suffix.

PRACTICAL GUARDRAILS

Common Failure Modes

Reference-based evaluation breaks in predictable ways. These are the most common failure modes when comparing outputs against golden references, with concrete guardrails to catch them before they reach production.

01

Exact-Match Tunnel Vision

What to watch: The evaluator penalizes semantically equivalent outputs because they use different words, phrasing, or sentence structure than the reference. This inflates false negatives and rejects valid variations. Guardrail: Add explicit semantic equivalence rules to the rubric, including acceptable paraphrase boundaries and synonym lists. Use embedding similarity as a secondary signal when exact-match fails below threshold.

02

Reference Contamination Drift

What to watch: Golden references grow stale as domain knowledge, terminology, or expected output formats change. The evaluator keeps passing outputs that match outdated references while failing correct modern responses. Guardrail: Version-lock references with expiration dates and trigger mandatory review when reference age exceeds threshold. Run periodic reference-audit prompts that check for outdated claims, deprecated APIs, or stale terminology.

03

Partial-Credit Collapse

What to watch: The evaluator treats multi-part outputs as binary pass/fail, missing cases where most fields are correct but one section is wrong. This hides incremental regressions and makes debugging harder. Guardrail: Decompose the reference into independently scored sections with explicit partial-credit rules. Require per-section scoring before aggregation, and flag outputs where overall score passes but a critical subsection fails.

04

Length Bias in Similarity Scoring

What to watch: Longer outputs get inflated similarity scores because they contain more tokens that happen to match the reference, even when they include hallucinated content. Short, precise outputs are unfairly penalized. Guardrail: Normalize similarity scores by output length or use precision-weighted metrics that penalize extraneous content. Add a conciseness check that flags outputs exceeding reference length by more than a configurable ratio.

05

Order-Dependent False Negatives

What to watch: The evaluator expects list items, steps, or arguments in the same order as the reference. Correct outputs with different ordering fail despite containing all required information. Guardrail: Use set-based comparison for unordered elements and sequence-aware comparison only where order is semantically meaningful. Explicitly mark ordered vs. unordered fields in the reference schema.

06

Threshold Boundary Instability

What to watch: Outputs scoring just above or below the pass/fail threshold flip between runs due to minor scoring noise, creating non-deterministic gate behavior. This erodes trust in the eval harness. Guardrail: Implement a gray zone around the threshold where outputs are flagged for human review rather than auto-passed or auto-failed. Run each borderline output through multiple eval passes and require consensus before final classification.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test whether the Reference-Based Evaluation Prompt correctly distinguishes acceptable paraphrases from semantic divergences. Each criterion targets a known failure mode in similarity scoring.

CriterionPass StandardFailure SignalTest Method

Semantic Equivalence Detection

Score >= 0.90 for true paraphrases with identical meaning

Score < 0.70 on a known-good paraphrase pair

Run 10 paraphrase pairs from [GOLDEN_PARAPHRASE_SET] and check min score

Semantic Divergence Detection

Score <= 0.30 for outputs that change a key fact

Score > 0.50 on a known-bad divergence pair

Run 10 divergence pairs from [GOLDEN_DIVERGENCE_SET] and check max score

Exact Match Recognition

Score == 1.00 when [CANDIDATE_OUTPUT] is identical to [REFERENCE_OUTPUT]

Score < 0.98 on an exact string match

Feed identical strings for both inputs and assert score equals 1.00

Partial Credit Granularity

Score falls in 0.40-0.80 range for partially correct outputs

Score is 0.0 or 1.0 for a mixed-correctness output

Use 5 partial-credit examples from [PARTIAL_CREDIT_SET] and verify scores are not binary

Acceptable Variation Boundary

Score >= 0.85 when only word order or synonyms differ

Score < 0.70 for a synonym-only rewrite

Run 5 synonym-rewrite pairs and check all scores exceed threshold

Citation Preservation Check

Score penalizes missing citations by >= 0.20 vs. cited version

Score difference < 0.10 when citations are stripped

Compare score for cited output vs. same output with [CITATION] tokens removed

Null or Empty Input Handling

Returns null or explicit error when [CANDIDATE_OUTPUT] is empty

Returns a numeric score for empty string input

Pass empty string as candidate and assert output is null or error message

Score Justification Completeness

Output includes a non-empty justification string for every score

Justification field is missing, null, or empty

Parse output schema and assert justification field is present and length > 0 for all 20 test pairs

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base template with a single reference per test case. Skip partial-credit rules and use a simple 1–5 similarity score with a brief justification. Run against 10–20 golden examples to get a feel for score distributions before tuning thresholds.

code
[SYSTEM]: You are an output evaluator. Compare [CANDIDATE_OUTPUT] to [REFERENCE_OUTPUT]. Return a similarity score from 1 (completely different) to 5 (semantically identical) and a one-sentence justification.

Watch for

  • Score inflation when references are short or generic
  • No differentiation between exact match and acceptable paraphrase
  • Missing edge cases where the candidate is correct but phrased differently
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.