Inferensys

Prompt

Golden Set Deviation Diagnosis Prompt

A practical prompt playbook for QA engineers and AI product teams comparing a production response against a known-good golden answer to produce a structured diff of semantic drift, missing facts, hallucinated additions, and formatting violations.
Developer reviewing semantic search engine results on laptop, relevance scores visible, technical search demo.
PROMPT PLAYBOOK

When to Use This Prompt

Diagnose why a single production response failed an automated evaluation by comparing it against its golden answer.

This prompt is a single-pair diagnostic tool for QA engineers and AI reliability teams responding to an active eval alert. Its job is to take one production response that scored below threshold and its corresponding golden answer, then produce a structured deviation report. The report must separate acceptable paraphrasing from genuine quality regressions—semantic drift, missing facts, hallucinated additions, and formatting non-compliance—so the team can decide whether to roll back, patch the prompt, fix a retrieval gap, or tune the eval rubric itself.

Use this when an automated eval score drops and you need to understand the nature of the failure before acting. The ideal user has the production response, the golden answer, the eval rubric that flagged the failure, and ideally the trace context (retrieved passages, tool calls, or prior turns) that produced the response. The prompt expects these as explicit inputs and will return a categorized diff. Do not use this for pre-release regression testing against a full golden dataset; it is not designed for bulk comparison or statistical analysis. It is a root-cause investigation tool for a single failure instance.

Before running this prompt, confirm that the eval failure is not a known infrastructure issue, a model provider outage, or a deployment misconfiguration. If the failure is part of a broader incident, use the Incident Trace Correlation prompt first to isolate common patterns. If you suspect the golden answer itself is stale or contaminated, run the Golden Set Contamination Check prompt before diagnosing the deviation. This prompt assumes the golden answer is trustworthy; if it is not, the deviation report will mislead you. After receiving the report, if the root cause points to a retrieval gap, hand off to the Retrieval Gap Root-Cause prompt. If it points to a prompt version regression, use the Prompt Version Rollback Trigger Analysis prompt to decide on a rollback.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Golden Set Deviation Diagnosis Prompt works and where it introduces risk. Use these cards to decide if this prompt fits your investigation workflow before wiring it into production tooling.

01

Good Fit: Structured Diff Against a Known Answer

Use when: you have a production response and a pre-approved golden answer for the same input. The prompt excels at producing a structured, category-level diff that separates semantic drift from acceptable paraphrasing. Guardrail: always provide both the golden answer and the production response in the prompt input; missing either turns the diagnosis into guesswork.

02

Bad Fit: No Golden Answer Exists

Avoid when: you only have a failing eval score but no canonical correct answer to compare against. Without a golden answer, the prompt cannot distinguish between a genuine quality regression and a poorly calibrated eval rubric. Guardrail: use the Eval Failure Root-Cause Triage Prompt instead when only eval scores and traces are available.

03

Required Inputs: Golden Answer, Production Response, and Rubric Dimensions

Risk: incomplete inputs produce unreliable diffs. The prompt needs the golden answer, the production response, and the quality dimensions to check. Guardrail: validate that all three inputs are present before invoking the prompt. If the eval rubric is implicit, explicitly list the dimensions you want compared.

04

Operational Risk: Over-Trusting the Diff Without Human Review

Risk: the prompt may flag acceptable paraphrasing as semantic drift or miss subtle factual errors that a domain expert would catch. Guardrail: route diffs with high-severity findings to human review before accepting them as root-cause evidence. Use the diff as an investigation accelerator, not a final verdict.

05

Operational Risk: Golden Set Contamination

Risk: if the golden answer was inadvertently included in the model's training data or few-shot examples, the diff will be misleadingly clean. Guardrail: run the Golden Set Contamination Check Prompt before relying on deviation diagnosis results for high-stakes decisions.

06

Variant: Multi-Dimensional Severity Classification

Use when: you need to triage multiple deviation types by severity before deep-dive investigation. Extend the prompt to classify each deviation as critical, moderate, or cosmetic. Guardrail: define severity thresholds explicitly in the prompt to avoid inconsistent classification across runs.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A copy-ready prompt for comparing a production response against a golden-set answer to produce a structured deviation diagnosis.

The prompt below is designed for a QA engineer or AI reliability developer who has a known-good reference answer and a production response that may have drifted. It forces the model to act as a forensic comparator, not a creative writer. The output is a structured diff that separates acceptable paraphrasing from genuine regressions, making it suitable for automated eval pipelines or manual triage. Before using this prompt, ensure you have the production trace available for context, as the model may need to reference retrieval steps or tool calls to explain certain deviations.

code
You are a forensic QA comparator. Your task is to compare a production response against a golden-set reference answer and produce a structured deviation diagnosis.

## INPUTS
- Golden Answer: [GOLDEN_ANSWER]
- Production Response: [PRODUCTION_RESPONSE]
- Evaluation Rubric Dimensions: [RUBRIC_DIMENSIONS]
- Production Trace Summary (optional): [TRACE_SUMMARY]

## CONSTRAINTS
- Do not rewrite or improve either answer. Only compare.
- Treat the golden answer as the ground truth for factual content.
- Distinguish between acceptable paraphrasing and genuine quality regressions.
- If the production response adds information not in the golden answer, flag it as a potential hallucination unless the trace summary confirms it came from retrieved context.
- If the golden answer contains information missing from the production response, flag it as a factual omission.
- For formatting violations, compare against the expected output schema: [OUTPUT_SCHEMA].

## OUTPUT FORMAT
Return a JSON object with the following structure:
{
  "verdict": "PASS" | "FAIL" | "REVIEW_REQUIRED",
  "summary": "One-sentence summary of the comparison outcome.",
  "deviations": [
    {
      "type": "semantic_drift" | "factual_omission" | "hallucinated_addition" | "format_violation" | "acceptable_paraphrase",
      "severity": "CRITICAL" | "MAJOR" | "MINOR" | "INFO",
      "golden_excerpt": "Relevant excerpt from the golden answer.",
      "production_excerpt": "Relevant excerpt from the production response.",
      "explanation": "Why this deviation matters and which rubric dimension it affects.",
      "trace_correlation": "If trace summary is provided, note any trace event that explains this deviation."
    }
  ],
  "rubric_dimension_scores": {
    "[DIMENSION_NAME]": {
      "score": 0-100,
      "justification": "Brief explanation of the score."
    }
  },
  "requires_human_review": true | false,
  "human_review_reason": "If requires_human_review is true, explain why."
}

## INSTRUCTIONS
1. Parse both answers and identify all factual claims, structural elements, and formatting choices.
2. Compare each claim in the golden answer against the production response. Flag omissions.
3. Compare each claim in the production response against the golden answer. Flag additions not explained by the trace.
4. Evaluate formatting against the output schema. Flag structural violations.
5. Score each rubric dimension based on the deviations found.
6. Set verdict to PASS if no CRITICAL or MAJOR deviations exist. Set to FAIL if any CRITICAL deviation exists. Set to REVIEW_REQUIRED if MAJOR deviations exist without CRITICAL ones.
7. If the trace summary is provided, correlate deviations to trace events where possible.

Adapt this template by replacing the square-bracket placeholders with your actual data. The [RUBRIC_DIMENSIONS] placeholder should contain a list of the specific quality dimensions you are evaluating, such as factual accuracy, completeness, citation correctness, or tone. The [OUTPUT_SCHEMA] placeholder should describe the expected structure of the production response, including required fields, types, and formatting rules. If you do not have a trace summary, remove the [TRACE_SUMMARY] placeholder and the trace correlation instructions. For high-stakes domains like healthcare or finance, always set requires_human_review to true for any FAIL or REVIEW_REQUIRED verdict and route the output to a human reviewer before taking action. Test this prompt against at least five known deviation cases before integrating it into an automated pipeline to calibrate severity thresholds for your specific use case.

IMPLEMENTATION TABLE

Prompt Variables

Every placeholder required by the Golden Set Deviation Diagnosis Prompt. Validate each input before sending to ensure the model receives complete, well-formed data for accurate diffing and root-cause analysis.

PlaceholderPurposeExampleValidation Notes

[GOLDEN_RESPONSE]

The known-good reference answer against which the production response is compared.

The patient's primary diagnosis is community-acquired pneumonia (CAP) with a CURB-65 score of 1.

Schema check: must be a non-empty string. Verify this is the authoritative, reviewed answer, not a draft or a previous model output.

[PRODUCTION_RESPONSE]

The actual model output from the production trace that failed evaluation.

The patient likely has a respiratory infection, possibly pneumonia. Consider antibiotics.

Schema check: must be a non-empty string. Ensure this is the exact raw output from the trace, not a redacted or summarized version.

[EVAL_RUBRIC_DIMENSIONS]

A list of specific quality dimensions the eval measured, defining what 'deviation' means.

["factual_accuracy", "completeness", "hallucination_rate", "format_compliance"]

Schema check: must be a valid JSON array of strings. Each dimension must map to a concrete, measurable property. Reject empty arrays.

[EVAL_SCORES]

The numerical or categorical scores assigned to the production response for each rubric dimension.

{"factual_accuracy": 0.4, "completeness": 0.6, "hallucination_rate": 0.8, "format_compliance": 1.0}

Schema check: must be a valid JSON object with keys matching [EVAL_RUBRIC_DIMENSIONS]. Values must be numbers or enums. Null values allowed only if the dimension was not scored.

[TRACE_CONTEXT]

Optional. Retrieved documents, tool outputs, or prior turns that were in the model's context window during generation.

[{"source": "doc_42.pdf", "snippet": "CURB-65 score of 1: Confusion absent, BUN < 20 mg/dL..."}]

Schema check: if provided, must be a valid JSON array of objects. Each object must have a source identifier. Null allowed if no retrieval or tools were used.

[ACCEPTABLE_PARAPHRASE_THRESHOLD]

A semantic similarity score (0-1) below which a difference is flagged as a genuine deviation rather than acceptable rewording.

0.85

Type check: must be a float between 0.0 and 1.0. Default to 0.85 if not specified. A lower threshold increases false negatives for semantic drift.

[HALLUCINATION_SEVERITY_SCALE]

A mapping defining how to classify hallucinated statements by severity.

{"critical": "contradicts golden answer or introduces harmful advice", "major": "adds unsupported clinical claim", "minor": "adds plausible but unverified detail"}

Schema check: must be a valid JSON object with at least one severity level defined. Each value must be a non-empty string describing the classification criteria.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Golden Set Deviation Diagnosis Prompt into an automated eval failure investigation pipeline.

This prompt is designed to operate as a diagnostic step within an automated eval failure pipeline, not as a standalone manual review tool. When a production response fails a quality eval against a golden set, the pipeline should automatically invoke this prompt with the failed response, the golden answer, the eval rubric, and the relevant trace segments. The prompt's structured diff output becomes the primary evidence packet for root-cause classification, enabling the system to route the failure to the correct remediation workflow—prompt rollback, retrieval tuning, few-shot example refresh, or human review—without requiring an engineer to manually reconstruct what went wrong.

Integration pattern: The prompt expects four inputs that must be assembled programmatically before invocation. [PRODUCTION_RESPONSE] comes from the response store or trace log. [GOLDEN_ANSWER] is fetched from the golden set database using the test case ID attached to the eval failure event. [EVAL_RUBRIC] is the specific rubric that flagged the failure, including the dimension scores and the failing threshold. [TRACE_CONTEXT] should include the retrieved passages, tool-call outputs, and any truncated context-window evidence from the production trace—this is critical for distinguishing a hallucination from a retrieval gap. Validation layer: Before the prompt output enters any automated decision path, apply a schema validator that checks for the required fields (deviation_category, semantic_drift, missing_facts, hallucinated_additions, formatting_violations, severity, trace_evidence_links). If the output fails schema validation, retry once with a stricter [OUTPUT_SCHEMA] constraint. If it fails again, escalate to a human reviewer with the raw trace and both responses attached.

Model selection and cost: This is a reasoning-heavy diagnostic task that benefits from a capable model with strong instruction-following and structured output discipline. Use a model with JSON mode or structured output support (e.g., GPT-4o, Claude 3.5 Sonnet, or equivalent). Do not route this to a lightweight or cost-optimized model—false negatives in deviation detection will cause the pipeline to miss regressions that should trigger rollbacks. Logging and audit: Every invocation should log the full prompt input, the structured diff output, the eval failure event ID, and the pipeline's routing decision. This audit trail is essential for retrospective analysis when a deviation pattern recurs across multiple failures. Human review gate: For any deviation classified as severity: critical or where hallucinated_additions contains claims about regulated domains (healthcare, finance, legal), the pipeline must not auto-remediate. Route to a human review queue with the structured diff pre-filled as the investigation starting point. Next step: After the deviation is diagnosed, feed the structured output into the appropriate remediation prompt—Prompt Version Rollback Trigger Analysis for regression patterns, Retrieval Gap Root-Cause for Eval Failure for missing evidence, or Hallucination Spot-Check Against Eval Rubric for verification before action.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, types, and validation rules for the JSON deviation report produced by the Golden Set Deviation Diagnosis Prompt. Use this contract to validate the model's output before accepting it into your QA pipeline.

Field or ElementType or FormatRequiredValidation Rule

deviation_report.deviations

Array of objects

Must be a JSON array. If no deviations found, return an empty array. Parse check: valid JSON. Schema check: each element must match the deviation object schema.

deviation_report.deviations[].deviation_id

String (kebab-case)

Must match pattern dev-### where ### is a zero-padded integer starting at 001. Uniqueness check: no duplicate IDs within the array.

deviation_report.deviations[].category

Enum string

Must be one of: semantic_drift, missing_fact, hallucinated_addition, format_violation, tone_shift, citation_error, ordering_change. Enum check: reject any value not in this set.

deviation_report.deviations[].severity

Enum string

Must be one of: critical, major, minor, cosmetic. Severity must be consistent with category: hallucinated_addition and missing_fact must be at least major. Cross-field validation required.

deviation_report.deviations[].location.production_span

String or null

Exact substring from the production response where the deviation occurs. If the deviation is an omission, set to null. Null check: null allowed only when category is missing_fact.

deviation_report.deviations[].location.golden_span

String or null

Exact substring from the golden answer that the production response should have matched. If the deviation is an addition, set to null. Null check: null allowed only when category is hallucinated_addition.

deviation_report.deviations[].explanation

String (1-3 sentences)

Must describe what deviated and why it matters. Length check: 30-500 characters. Must not simply restate the category name. Must reference specific content from both spans.

deviation_report.deviations[].acceptable_paraphrase

Boolean

Must be true if the deviation is a semantically equivalent reformulation that should not count as a regression, false otherwise. If true, severity must be cosmetic. Cross-field validation required.

deviation_report.summary.total_deviations

Integer

Must equal the length of the deviations array. Count check: if array is empty, must be 0. If array has elements, must match exactly.

deviation_report.summary.critical_count

Integer

Must equal the count of deviations with severity critical. Sum check: critical_count + major_count + minor_count + cosmetic_count must equal total_deviations.

deviation_report.summary.regression_verdict

Enum string

Must be one of: regression_confirmed, regression_unlikely, needs_human_review. If any deviation has severity critical and acceptable_paraphrase is false, verdict must be regression_confirmed. Cross-field validation required.

PRACTICAL GUARDRAILS

Common Failure Modes

When diagnosing golden set deviations, these failure modes surface most often in production. Each card explains what breaks first and how to guard against it before shipping the prompt.

01

Acceptable Paraphrasing Flagged as Regression

What to watch: The prompt treats semantically equivalent rephrasing as a deviation, flooding the diff with false positives. This happens when the rubric overweights surface-form matching instead of semantic equivalence. Guardrail: Include explicit criteria distinguishing acceptable paraphrasing (same facts, different wording) from genuine regressions (missing facts, added claims, changed meaning). Calibrate with a threshold that ignores low-signal lexical diffs.

02

Hallucinated Additions Passing as Elaboration

What to watch: The model adds plausible-sounding details not present in the golden answer, and the diff fails to flag them because they appear contextually reasonable. This is especially dangerous in regulated domains where unsupported claims carry compliance risk. Guardrail: Require every factual claim in the production response to map to either the golden answer or retrieved evidence. Flag any claim without a source anchor as a potential hallucination, regardless of plausibility.

03

Missing Critical Facts with High Semantic Similarity

What to watch: The production response scores well on embedding similarity but omits key facts present in the golden answer. Cosine similarity masks information loss when the remaining text is topically close. Guardrail: Add a fact-recall dimension to the evaluation that extracts discrete facts from both responses and computes precision-recall, not just overall similarity. Flag responses below a recall threshold even if similarity scores are high.

04

Formatting Violations Masking Content Quality

What to watch: The prompt conflates structural format issues with content quality, producing diffs that bury semantic problems under a flood of whitespace, bullet-style, or heading-level complaints. Guardrail: Separate format compliance checks from content quality checks in the output schema. Run format validation first, normalize both responses to a canonical structure, then compare content. Report format violations independently so they don't obscure factual regressions.

05

Golden Set Contamination Producing False Confidence

What to watch: The golden answer or its near-duplicate appears in the model's training data, few-shot examples, or retrieved context, causing the production response to match artificially well. The diff shows no deviations, but the result is untrustworthy. Guardrail: Before trusting a clean diff, verify that the golden answer hasn't leaked into the prompt context, retrieval index, or demonstration set. Rotate golden examples periodically and test with held-out cases that are provably absent from training data.

06

Context Window Truncation Silently Dropping Evidence

What to watch: The production response deviates from the golden answer because required evidence was truncated from the context window, but the diff attributes the failure to model behavior rather than retrieval infrastructure. Guardrail: Include a context-attribution step that checks whether the evidence needed for the golden answer was actually present in the model's context window. When evidence is missing, classify the deviation as a retrieval gap, not a generation failure, and route to the retrieval pipeline team.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for testing the quality of the deviation report itself before relying on it for production decisions. Each row defines a pass standard, a failure signal, and a concrete test method.

CriterionPass StandardFailure SignalTest Method

Semantic Drift Classification Accuracy

Report correctly labels acceptable paraphrasing as 'PASS' and genuine meaning changes as 'FAIL' for at least 90% of test pairs

Report labels a synonym substitution as a regression or misses a factual contradiction

Run against a labeled calibration set of 20 golden-vs-production pairs with known drift labels; measure precision and recall

Factual Addition Detection

Report identifies all hallucinated facts present in the production response but absent from the golden answer

Report misses an invented statistic, name, date, or claim not present in the golden answer

Inject 5 known hallucinations into a production response; verify all 5 appear in the report's 'hallucinated_additions' field

Factual Omission Detection

Report identifies all material facts present in the golden answer but missing from the production response

Report fails to flag a missing critical number, entity, or constraint that changes the answer's usefulness

Remove 3 key facts from a golden answer to create a test production response; verify all 3 appear in the report's 'missing_facts' field

Formatting Violation Flagging

Report correctly identifies deviations from the expected output schema, including type changes, missing required fields, and structural differences

Report passes a response with a missing required field or a string where an integer is expected

Provide a production response with 3 intentional schema violations; confirm the report's 'formatting_violations' list contains all 3 with correct field paths

Source Attribution Accuracy

Report correctly links each deviation to the specific trace event, tool call, or retrieval step that likely caused it

Report attributes a hallucination to retrieval when the retrieved context was correct, or blames the model when a tool returned bad data

Use a trace with known ground-truth causation; verify the report's 'likely_cause' field matches the injected root cause for each deviation

Severity Classification Consistency

Report assigns severity levels consistent with a predefined rubric across multiple runs on the same input

Same deviation pair receives 'CRITICAL' on one run and 'MINOR' on another without input changes

Run the prompt 5 times on the same golden-vs-production pair with temperature=0; verify severity labels are identical across all runs

Confidence Calibration

Report's confidence scores correlate with actual correctness: high-confidence deviations are accurate, low-confidence flags are genuinely uncertain

Report assigns 0.95 confidence to an incorrect deviation flag or 0.30 confidence to an obvious, clear-cut regression

Compare confidence scores against human-judged correctness on 30 deviation flags; expect Brier score below 0.15

Output Schema Compliance

The report itself is valid JSON matching the expected [OUTPUT_SCHEMA] with all required fields present and correctly typed

Report JSON fails to parse, contains extra untyped fields, or uses wrong types for required fields

Validate report output against the JSON Schema definition; require parse success and schema validation pass before any other test

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single golden answer and production response pair. Drop the structured diff schema initially and ask for a free-text comparison. Focus on getting the model to identify semantic drift, missing facts, and hallucinations without enforcing strict output formatting.

Simplify the prompt to:

code
Compare this production response against the golden answer. Identify:
- Facts present in golden but missing from production
- Facts in production but absent from golden (potential hallucinations)
- Semantic differences that change meaning
- Formatting violations

Golden: [GOLDEN_ANSWER]
Production: [PRODUCTION_RESPONSE]

Watch for

  • The model conflating acceptable paraphrasing with semantic drift
  • Over-flagging minor wording differences as regressions
  • Missing subtle factual omissions when the production response sounds fluent
  • No structured severity classification, making it hard to prioritize findings
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.