Inferensys

Prompt

LLM Judge Failure Mode Classification Prompt Template

A practical prompt playbook for classifying model output failures into a structured taxonomy with confidence scores and evidence pointers, designed for evaluation platform teams building automated debugging pipelines.
AI evaluator reviewing output quality on laptop, comparison metrics visible, casual evaluation session.
PROMPT PLAYBOOK

When to Use This Prompt

Determine if automated failure mode classification is the right tool for your debugging pipeline and when to fall back to manual review.

This prompt is designed for evaluation platform teams who need to move beyond binary pass/fail signals and into automated root-cause diagnosis. The primary job-to-be-done is routing a model output that has already failed a quality gate to the correct remediation path. Instead of a human manually inspecting every failure to decide whether it's a hallucination, a format error, a refusal, or a reasoning break, this prompt produces a structured classification label, a confidence score, and an evidence pointer that your downstream pipeline can act on. The ideal user is an AI engineer or evaluation lead building an automated debugging harness where speed and consistency matter more than perfect accuracy on edge cases.

You should use this prompt when you have a known-failing output, the original input that produced it, and any relevant context or source material that was available to the model at generation time. The prompt assumes the failure has already been detected by an upstream quality gate—such as a groundedness check, a schema validator, or a safety classifier. It does not replace that gate. Instead, it answers the question: 'Now that we know this output is bad, what kind of bad is it?' This classification then feeds into automated remediation: hallucination outputs go to fact-repair loops, format errors go to schema correction, refusals go to policy review, and reasoning breaks go to chain-of-thought debugging. The prompt is most effective when your failure taxonomy is stable and your remediation paths are well-defined.

Do not use this prompt as a substitute for human review in high-risk domains such as healthcare, legal, finance, or safety-critical systems. The classification it produces is a first-pass diagnosis intended to accelerate human triage or feed automated repair pipelines with low downstream risk. It is not a final judgment. Avoid using this prompt when the failure mode taxonomy is ambiguous or when multiple failure modes overlap in ways that require nuanced human judgment. Also avoid it when the cost of misclassification is high and the confidence score is likely to be low—for example, when the original input is adversarial, the context is contradictory, or the model output is so garbled that even a human would struggle to categorize the failure. In those cases, route directly to a human review queue with the raw evidence attached.

PRACTICAL GUARDRAILS

Use Case Fit

Where the LLM Judge Failure Mode Classification Prompt works well, where it breaks down, and what you need in place before relying on it in production.

01

Good Fit: Structured Taxonomy Mapping

Use when: you have a predefined, stable taxonomy of failure modes (hallucination, refusal, format error, reasoning break, etc.) and need consistent labels across thousands of evaluations. Guardrail: validate taxonomy coverage monthly against new failure patterns discovered in production logs.

02

Bad Fit: Novel or Ambiguous Failures

Avoid when: failure modes are poorly understood, taxonomy is still evolving, or outputs require deep domain expertise to judge. The classifier will force-fit ambiguous cases into existing buckets. Guardrail: maintain an 'uncategorized' bucket with a confidence threshold and route low-confidence classifications to human review.

03

Required Inputs

What you need: the original model output, the input context that produced it, the expected behavior or rubric, and any tool call traces or retrieved evidence. Guardrail: build a schema that validates all required fields are present before invoking the classifier; missing context produces unreliable root cause labels.

04

Operational Risk: Taxonomy Drift

Risk: failure mode definitions shift as your product evolves, but the classifier prompt stays frozen. Labels become inconsistent with current expectations. Guardrail: version your taxonomy alongside your prompt, run calibration tests quarterly against human-labeled samples, and track classification distribution shifts.

05

Operational Risk: Confidence Overstatement

Risk: the LLM judge assigns high confidence to incorrect failure mode classifications, especially on borderline cases. Guardrail: require evidence pointers in the output (specific spans or reasoning steps) and implement a second-pass verification for high-severity failure modes before triggering automated remediation.

06

When to Escalate Beyond the Prompt

Escalate when: failure classification directly triggers production rollbacks, user-facing error messages, or compliance reports. Guardrail: insert a human-in-the-loop step for classifications that drive high-stakes actions; use the prompt output as a triage suggestion, not an automated decision.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A production-ready prompt for classifying LLM output failures into a structured taxonomy with confidence scores and evidence pointers.

This prompt template is designed to be dropped directly into your evaluation harness. It instructs an LLM judge to analyze a failed model output against its original input and instructions, then classify the failure into a structured taxonomy. The template uses square-bracket placeholders that you must replace at runtime with actual values from your pipeline—the original user input, the system prompt or instructions, the model's failing output, and your specific failure taxonomy. The output is a strict JSON object containing the primary failure mode, a confidence score, a concise evidence quote, and a brief reasoning trace. This structure ensures that downstream debugging tools and dashboards receive consistent, machine-readable diagnostics.

text
You are an expert AI output auditor. Your task is to analyze a model output that has been flagged as a failure and classify the failure mode.

## INPUT
[INPUT]

## SYSTEM INSTRUCTIONS
[SYSTEM_PROMPT]

## MODEL OUTPUT (FLAGGED AS FAILURE)
[FAILING_OUTPUT]

## FAILURE MODE TAXONOMY
[FAILURE_TAXONOMY]

## INSTRUCTIONS
1. Review the INPUT, SYSTEM INSTRUCTIONS, and FAILING_OUTPUT carefully.
2. Identify the single most specific failure mode from the FAILURE MODE TAXONOMY that best explains why the output failed.
3. Quote the shortest exact string from the FAILING_OUTPUT that serves as primary evidence for this failure.
4. Provide a concise, step-by-step reasoning trace that connects the evidence to the chosen failure mode.
5. Assign a confidence score between 0.0 and 1.0 reflecting how certain you are in this classification.

## OUTPUT SCHEMA
You must respond with a single JSON object conforming to this schema:
{
  "failure_mode": "string (exact value from taxonomy)",
  "confidence": number (0.0 to 1.0),
  "evidence_quote": "string (exact substring from FAILING_OUTPUT)",
  "reasoning_trace": "string (step-by-step explanation)"
}

## CONSTRAINTS
- Do not output any text outside the JSON object.
- The evidence_quote must be a verbatim substring of the FAILING_OUTPUT. If no single quote captures the evidence, use the most representative substring.
- If multiple failure modes apply, choose the most specific or root-cause mode.
- If the failure does not match any taxonomy entry, set failure_mode to "unclassified" and explain why in the reasoning_trace.

To adapt this template, replace the placeholders with data from your evaluation pipeline. [INPUT] should contain the original user query or task. [SYSTEM_PROMPT] should contain the full system instructions given to the model under test. [FAILING_OUTPUT] is the raw, unedited output that your primary evaluator or a human reviewer flagged as incorrect. [FAILURE_TAXONOMY] is a critical customization point: provide a newline-separated list or JSON array of your organization's specific failure categories, such as hallucination, refusal, format_error, reasoning_break, tool_call_error, or context_contamination. The quality of classification depends heavily on a well-defined, mutually exclusive taxonomy. Before deploying, run this prompt against a golden set of 50–100 known failures with human-verified labels to calibrate confidence thresholds and identify taxonomy gaps. In high-stakes domains, route classifications with confidence below 0.85 to a human review queue.

IMPLEMENTATION TABLE

Prompt Variables

Each placeholder the LLM Judge Failure Mode Classification prompt needs to work reliably, with validation notes for production harness integration.

PlaceholderPurposeExampleValidation Notes

[MODEL_OUTPUT]

The full text or structured output from the model under evaluation that may contain a failure

{"answer": "The capital of France is London.", "citations": [{"doc_id": "d1", "text": "Paris is the capital of France."}]}

Required. Must be non-empty string or valid JSON object. Reject null or whitespace-only inputs before prompt assembly.

[TASK_CONTEXT]

Description of what the model was asked to do, including any constraints or expected output format

Answer the user question using only the provided context. If the context does not contain the answer, state that you cannot answer.

Required. Must include the original instruction and any format or behavioral constraints. Validate that this matches the actual prompt version used at inference time.

[SOURCE_MATERIAL]

Ground-truth context, reference documents, or expected answer that the model should have used

Paris is the capital of France. It has been the capital since 987 AD.

Optional but strongly recommended. When present, enables hallucination and groundedness classification. Validate that source material matches what was actually provided to the model at inference time, not a later version.

[FAILURE_TAXONOMY]

The structured list of failure categories the judge must choose from, with definitions and examples

["hallucination", "refusal", "format_error", "reasoning_break", "incomplete", "irrelevant", "contradiction", "overconfidence", "no_failure"]

Required. Must be a closed set of labels with unambiguous definitions. Validate that taxonomy version matches the evaluation pipeline config. Reject if taxonomy contains overlapping categories without tie-breaking rules.

[OUTPUT_SCHEMA]

The exact JSON schema the judge must return, including required fields and allowed values

{"failure_mode": "string", "confidence": 0.0-1.0, "evidence_span": "string or null", "explanation": "string", "severity": "low|medium|high|critical"}

Required. Must be a valid JSON Schema or TypeScript interface. Validate judge output against this schema programmatically after generation. Reject judge responses that don't conform.

[CONFIDENCE_THRESHOLD]

Minimum confidence score below which the classification should be flagged for human review

0.7

Required. Must be a float between 0.0 and 1.0. Classifications below this threshold should route to human review queue. Validate that threshold is set based on calibration data, not arbitrary choice.

[FEW_SHOT_EXAMPLES]

2-4 annotated examples showing correct classification with evidence pointers and confidence calibration

[{"output": "I cannot answer that.", "task": "Answer from context", "source": "Paris is capital.", "classification": "refusal", "confidence": 0.95, "evidence": "Model declined despite relevant context present"}]

Optional but recommended for consistency. Validate that examples cover distinct failure modes and include edge cases. Check that examples don't leak test-set cases into the judge prompt.

[MAX_OUTPUT_LENGTH]

Token or character limit for the judge's explanation field to prevent verbose justifications from dominating eval cost

300 tokens

Optional. Default to 500 tokens if not set. Validate that explanation truncation doesn't remove evidence pointers. Monitor for truncated explanations in production logs.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the failure mode classification prompt into an automated evaluation and debugging pipeline.

The LLM Judge Failure Mode Classification Prompt Template is designed to be called programmatically after a primary evaluation judge has flagged an output as a failure. It should not be used as a standalone classifier on raw outputs without a prior failure signal, because running detailed root-cause analysis on every response wastes tokens and latency. The typical integration pattern is: (1) a primary pass/fail or scoring judge evaluates the model output, (2) outputs scoring below a threshold or flagged as FAIL are routed to this classification prompt, and (3) the structured classification result is written to an observability store for aggregation and alerting.

Wire the prompt into your pipeline with a retry wrapper that handles malformed JSON, missing required fields, or confidence scores below a minimum threshold (e.g., confidence < 0.7). On parse failure, retry once with the raw model response and a repair instruction appended: The previous output was not valid JSON matching the required schema. Return ONLY the corrected JSON object. If the retry also fails, log the raw output and escalate for human review. For high-throughput pipelines, implement a circuit breaker that stops calling the classification judge if the error rate exceeds 10% over a rolling window, preventing cascading failures from a judge model degradation.

Model choice matters here. Use a model with strong instruction-following and structured output capabilities—GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro are appropriate defaults. Avoid smaller or older models (GPT-3.5, Claude Haiku) for this task because the classification taxonomy requires nuanced distinction between categories like reasoning_break and hallucination. If you must use a smaller model for cost reasons, reduce the taxonomy to 3-4 coarse categories and increase the confidence threshold for auto-acceptance. Always log the full prompt payload, model response, parse result, and any retry attempts to your observability platform. This trace data is essential for debugging classification drift and for building eval datasets that measure whether your judge is correctly attributing failures over time.

Before deploying to production, run this prompt against a seeded failure dataset where you've injected known failure modes (e.g., deliberately truncated context to trigger context_loss, inserted fabricated claims to trigger hallucination, removed required fields to trigger format_error). Measure precision and recall per failure category. If the judge consistently confuses refusal with safety_overblock, refine the category definitions in the prompt's taxonomy section. Wire these seeded tests into your CI/CD pipeline as a regression gate: any prompt change that degrades classification accuracy on known failures should block deployment until the taxonomy or instructions are corrected.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, data types, validation rules, and pass/fail conditions for the LLM Judge Failure Mode Classification response. Use this contract to parse, validate, and act on the classifier output in your debugging pipeline.

Field or ElementType or FormatRequiredValidation Rule

failure_mode

enum string

Must match one of the defined taxonomy values: hallucination, refusal, format_error, reasoning_break, context_misuse, instruction_violation, tool_misuse, or other. Case-sensitive exact match required.

confidence_score

float

Must be a number between 0.0 and 1.0 inclusive. Reject if null, non-numeric, or outside range. Values below 0.5 should trigger human review flag.

evidence_spans

array of objects

Each object must contain start_char (int), end_char (int), and excerpt (string). start_char must be less than end_char. excerpt must be a substring of [INPUT_OUTPUT_PAIR] at the given character offsets. Array must not be empty when confidence_score >= 0.7.

evidence_spans[].start_char

integer

Non-negative integer. Must be less than end_char and within the character length of [INPUT_OUTPUT_PAIR].

evidence_spans[].end_char

integer

Non-negative integer. Must be greater than start_char and within the character length of [INPUT_OUTPUT_PAIR].

evidence_spans[].excerpt

string

Must exactly match the substring of [INPUT_OUTPUT_PAIR] from start_char to end_char. Whitespace-sensitive comparison. Reject on mismatch.

root_cause_summary

string

Must be a non-empty string between 10 and 500 characters. Must not be a verbatim copy of failure_mode. Should describe the specific trigger or mechanism observed.

suggested_fix

string or null

If failure_mode is other or confidence_score < 0.5, this field may be null. Otherwise must be a non-empty string between 10 and 300 characters with an actionable recommendation.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when classifying LLM output failures and how to guard against it.

01

Taxonomy Boundary Blur

What to watch: The judge conflates overlapping categories (e.g., hallucination vs. reasoning error) when the failure has multiple symptoms. The classifier picks the first plausible label instead of the root cause. Guardrail: Require the prompt to output a primary category plus a differential diagnosis list with evidence for each candidate. Test with seeded examples that sit on category boundaries.

02

Confidence Score Inflation

What to watch: The judge assigns high confidence to classifications even when evidence is thin or ambiguous. This hides uncertainty from downstream systems that rely on confidence thresholds for routing. Guardrail: Add a confidence calibration instruction that ties confidence to specific evidence markers. Validate against a human-labeled set where ambiguous cases are marked as such.

03

Evidence Pointer Hallucination

What to watch: The judge cites specific spans or line numbers as evidence for a failure mode, but those spans don't exist in the source or don't support the claim. This creates a false audit trail. Guardrail: Post-process evidence pointers by verifying they exist in the source text. Add a groundedness check that compares cited spans against the original output before accepting the classification.

04

Coverage Gap on Novel Failures

What to watch: The taxonomy doesn't include a category for a new failure mode, so the judge forces it into an existing bucket or labels it 'other' without useful detail. This masks emerging failure patterns. Guardrail: Include an 'unclassified' category with a required free-text description. Monitor the 'unclassified' rate and review weekly to identify taxonomy gaps before they become blind spots.

05

Input Length Truncation Artifacts

What to watch: Long outputs get truncated before classification, causing the judge to miss failure evidence in the tail. The classifier reports 'no failure' when the error is simply outside the visible window. Guardrail: Implement a pre-classification check that verifies the full output was received. If truncated, flag as 'insufficient evidence' rather than attempting classification on partial data.

06

Position Bias in Multi-Turn Failures

What to watch: In multi-turn conversations, the judge over-weights failures in the most recent turn and misses earlier root causes that cascaded forward. The classification blames the symptom, not the origin. Guardrail: Instruct the judge to trace failures backward through the conversation history and identify the earliest turn where the error originated. Test with seeded cascading failure scenarios.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the classifier's output quality before deploying it into your automated debugging pipeline. Each criterion targets a specific failure mode that breaks downstream trust in the classification.

CriterionPass StandardFailure SignalTest Method

Taxonomy Adherence

Failure mode label matches one of the allowed enum values in [TAXONOMY] exactly

Output contains a novel, misspelled, or out-of-taxonomy label

Validate output label against the allowed enum list. Reject any string not present in the taxonomy definition.

Evidence Grounding

At least one evidence pointer references a specific, verifiable span in [MODEL_OUTPUT] or [TRACE_LOG]

Evidence field is empty, contains only vague commentary, or points to a non-existent line

Parse evidence pointers and check for substring match in the source text. Flag if no pointer resolves to a real span.

Confidence Calibration

Confidence score is between 0.0 and 1.0 and correlates with evidence strength

Confidence is 0.99 for ambiguous cases or 0.1 for clear-cut failures with strong evidence

Run 20 known-ambiguous and 20 known-clear cases. Check that mean confidence differs significantly between the two sets.

Multi-Label Handling

When multiple failure modes are present, the primary label is the most impactful and secondary labels are listed in [SECONDARY_FAILURES]

Classifier picks a minor formatting issue as primary when a hallucination is also present

Inject test cases with two simultaneous failures. Verify hallucination or refusal always outranks format issues as primary.

Refusal vs. False Refusal Discrimination

Correctly distinguishes between legitimate safety refusals and false refusals on safe queries

Flags a safe but complex query as a refusal failure mode

Use a test set of 10 known-safe queries that resemble refusal triggers. Verify false refusal rate is below 5%.

Format Error Precision

Identifies the specific schema violation (missing field, wrong type, invalid enum) rather than a generic format error label

Output says format_error with no further breakdown when a specific field is malformed

Inject outputs with known schema violations. Check that the evidence pointer identifies the exact field and violation type.

Classification Consistency

Same input with minor paraphrasing of the model output produces the same primary failure label

Label flips between hallucination and reasoning_break when the underlying error is unchanged

Run 10 error cases through the classifier 3 times with slight wording variations. Require primary label agreement in at least 90% of runs.

Abstention on Clean Outputs

Returns a no_failure label with confidence above 0.8 when [MODEL_OUTPUT] has no detectable errors

Classifier invents a spurious failure mode for a correct, well-formed output

Feed 10 verified-clean outputs through the classifier. Require no_failure rate of at least 95%.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base taxonomy and a small set of known failure examples. Use a single model call without schema enforcement. Focus on getting the classification labels right before adding confidence scores or evidence pointers.

Replace the full taxonomy with 3–5 high-level categories:

  • hallucination
  • refusal
  • format_error
  • reasoning_break
  • other

Drop the [EVIDENCE] field and use a simple markdown table output instead of strict JSON.

Watch for

  • Taxonomy categories that overlap and confuse the judge
  • Outputs that explain the failure without assigning a label
  • Inconsistent capitalization or naming 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.