Inferensys

Prompt

Step-by-Step Reasoning Verification Against Reference Prompt Template

A practical prompt playbook for verifying model reasoning step-by-step against a reference solution in production evaluation pipelines. Use this when the reasoning path matters as much as the final answer.
ML engineer running AI model benchmarks, performance charts on multiple screens, late night home office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Identify the evaluation scenarios where step-level reasoning verification is the right tool and when simpler answer-only comparison is sufficient.

This prompt is designed for evaluation engineers and AI platform teams who need to verify that a model's reasoning process is logically sound, not just that the final answer matches a reference. It is built for reasoning-heavy tasks such as mathematical problem solving, multi-step code debugging, legal analysis, and scientific inference where a correct final answer can mask flawed intermediate logic. Use this prompt when you have a reference solution with explicit reasoning steps and you need an LLM judge to perform step-level alignment, flag logical gaps, and produce a structured verification report.

The prompt is not appropriate for grading creative writing, summarization quality, or tasks where multiple valid reasoning paths exist without a single authoritative reference. If your evaluation only needs to check whether the final answer matches a golden answer, use a simpler reference-guided comparison prompt instead. This prompt adds overhead—step alignment, gap detection, and justification generation—that is wasted when the reasoning path is irrelevant to the quality judgment. Reserve it for domains where incorrect intermediate logic is a failure even if the conclusion happens to be correct, such as regulatory compliance analysis, medical differential diagnosis, or safety-critical engineering calculations.

Before deploying this prompt, ensure you have a reference solution that includes explicit, enumerated reasoning steps. The prompt performs best when the reference breaks the problem into discrete logical units that can be aligned one-to-one with the model's output. If your reference is a single paragraph of prose without clear step boundaries, the alignment quality will degrade. Consider preprocessing your reference into numbered steps or using a separate decomposition prompt to extract steps before running this verification. For production pipelines, pair this prompt with a regression test harness that tracks step-level agreement rates over time and flags sudden drops that may indicate model behavior drift.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works, where it fails, and what you must provide before using it in a production evaluation pipeline.

01

Good Fit: Reasoning Model Evaluation

Use when: you are evaluating a reasoning model (e.g., o1, o3, Claude with extended thinking) where the logical path matters as much as the final answer. Why: this prompt performs step-by-step alignment, catching flawed reasoning that coincidentally reaches the correct output. Guardrail: always provide a reference solution with explicit, enumerated steps for the judge to align against.

02

Good Fit: Math and Logic Problem Grading

Use when: grading multi-step math proofs, code logic, or formal derivations where partial credit for intermediate steps is required. Why: the prompt decomposes both the model output and the reference into comparable steps, enabling granular scoring. Guardrail: define a tolerance for semantically equivalent but notationally different steps in your rubric to avoid false negatives.

03

Bad Fit: Creative or Subjective Tasks

Avoid when: evaluating creative writing, marketing copy, or open-ended brainstorming where no single correct reasoning path exists. Why: the prompt requires a deterministic reference path; forcing a creative output into step alignment will produce meaningless, overly strict scores. Guardrail: use pairwise comparison or rubric-based evaluation prompts for subjective tasks instead.

04

Bad Fit: Single-Step Factual Lookups

Avoid when: the task is a simple fact retrieval or single-step extraction where reasoning is trivial. Why: the overhead of step decomposition adds latency and noise without improving evaluation quality over a direct factual consistency check. Guardrail: route simple QA tasks to a reference-guided factual consistency prompt and reserve this template for multi-step reasoning.

05

Required Inputs: Reference Solution with Steps

Risk: without a clearly enumerated reference solution, the judge cannot perform step alignment and will hallucinate a comparison or fail silently. Guardrail: your reference must be a list of discrete, verifiable reasoning steps, not a paragraph of prose. Pre-process reference answers into a step array before calling this prompt.

06

Operational Risk: Judge Reasoning Drift

Risk: the LLM judge may itself make reasoning errors when comparing complex logical chains, especially in domains requiring specialized knowledge (e.g., advanced physics, niche legal reasoning). Guardrail: spot-check judge outputs against human expert evaluations, and calibrate the judge's step-level accuracy on a held-out set before trusting it in automated pipelines.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for step-by-step reasoning verification against a reference solution, ready to copy and adapt with your own inputs.

This prompt template is designed for evaluating reasoning-heavy model outputs where the path to the answer matters as much as the final result. Unlike simple answer-comparison prompts, this template instructs the judge model to decompose both the candidate output and the reference solution into discrete reasoning steps, then perform a step-level alignment and verification. Use this when you need to catch logical errors, skipped steps, or flawed intermediate conclusions that happen to land on the correct final answer. The template is model-agnostic and works with any LLM capable of structured, multi-step analysis.

Below is the copy-ready prompt template. Replace every square-bracket placeholder with your actual data before sending it to the model. The placeholders are designed to be self-contained: you should be able to fill them in without reading the rest of this playbook, though the surrounding sections explain how to wire this into a production evaluation harness.

text
You are an expert reasoning evaluator. Your job is to compare a candidate model's step-by-step reasoning against a reference solution and determine whether the reasoning is logically valid, complete, and aligned with the reference.

## INPUT

**Question or Problem Statement:**
[QUESTION]

**Candidate Reasoning and Answer:**
[CANDIDATE_OUTPUT]

**Reference Solution:**
[REFERENCE_SOLUTION]

## INSTRUCTIONS

1. Decompose the reference solution into a numbered sequence of discrete reasoning steps. Each step should represent one logical inference, calculation, or conclusion.

2. Decompose the candidate's reasoning into a numbered sequence of discrete reasoning steps using the same granularity.

3. For each reference step, identify the corresponding candidate step(s) that address the same logical move. Note if any reference step has no corresponding candidate step.

4. For each aligned pair, evaluate whether the candidate step is:
   - **CORRECT**: Logically equivalent to the reference step and free of errors.
   - **EQUIVALENT**: Different wording or approach but reaches the same intermediate conclusion.
   - **PARTIALLY_CORRECT**: Right direction but missing nuance, precision, or completeness.
   - **INCORRECT**: Contains a logical error, false statement, or invalid inference.
   - **MISSING**: The candidate does not address this step at all.

5. Identify any candidate steps that do not correspond to any reference step. Classify each as:
   - **EXTRA_VALID**: Additional valid reasoning not in the reference.
   - **EXTRA_IRRELEVANT**: Unrelated or unnecessary reasoning.
   - **EXTRA_ERRONEOUS**: Additional reasoning that contains errors.

6. Check whether the candidate's final answer matches the reference's final answer.

## OUTPUT FORMAT

Return a JSON object with this exact structure:

```json
{
  "reference_step_count": <integer>,
  "candidate_step_count": <integer>,
  "step_alignments": [
    {
      "reference_step_index": <integer>,
      "reference_step_summary": "<brief description of the reference step>",
      "candidate_step_indices": [<integers>],
      "alignment_judgment": "CORRECT" | "EQUIVALENT" | "PARTIALLY_CORRECT" | "INCORRECT" | "MISSING",
      "explanation": "<detailed explanation of the judgment>"
    }
  ],
  "unaligned_candidate_steps": [
    {
      "candidate_step_index": <integer>,
      "candidate_step_summary": "<brief description>",
      "classification": "EXTRA_VALID" | "EXTRA_IRRELEVANT" | "EXTRA_ERRONEOUS",
      "explanation": "<detailed explanation>"
    }
  ],
  "final_answer_match": true | false,
  "overall_assessment": {
    "reasoning_score": <float between 0.0 and 1.0>,
    "critical_errors": ["<description of any critical logical errors>"],
    "summary": "<narrative summary of reasoning quality>"
  }
}

CONSTRAINTS

  • Do not judge the reference solution itself. Assume it is correct.
  • Focus on logical validity, not writing style or verbosity.
  • If the candidate reaches the correct final answer through flawed reasoning, the reasoning score must reflect the errors.
  • If the candidate uses a different but valid approach, classify steps as EQUIVALENT rather than INCORRECT.
  • Be precise in your explanations. Vague judgments are not useful.
  • [ADDITIONAL_CONSTRAINTS]

To adapt this template for your own use, start by replacing [QUESTION] with the original problem or prompt that both the candidate model and the reference solution were responding to. Replace [CANDIDATE_OUTPUT] with the full text of the model output you're evaluating—include both the reasoning trace and the final answer. Replace [REFERENCE_SOLUTION] with your known-correct solution, which should include step-by-step reasoning, not just the final answer. The [ADDITIONAL_CONSTRAINTS] placeholder lets you add domain-specific rules, such as tolerance thresholds for numerical answers, required intermediate outputs, or forbidden reasoning patterns. If you don't need additional constraints, remove that line entirely rather than leaving the placeholder. The output schema is designed to be parseable by downstream evaluation infrastructure; do not modify the JSON structure unless you also update your parsing and aggregation code. For high-stakes domains where reasoning errors carry significant risk, always route outputs scoring below 0.8 to human review before accepting the evaluation.

IMPLEMENTATION TABLE

Prompt Variables

Placeholders required by the Step-by-Step Reasoning Verification prompt. Replace each before sending the prompt to the model. Validation notes describe how to check that the variable is well-formed before execution.

PlaceholderPurposeExampleValidation Notes

[STUDENT_SOLUTION]

The model-generated reasoning chain and final answer to evaluate

Step 1: Isolate x. 2x + 4 = 10 → 2x = 6 → x = 3. Final Answer: 3

Must be non-empty string. Check for minimum length of 20 characters to ensure reasoning is present, not just a final answer.

[REFERENCE_SOLUTION]

The known-correct step-by-step solution used as ground truth

Step 1: Subtract 4 from both sides. 2x = 6. Step 2: Divide by 2. x = 3. Final Answer: 3

Must be non-empty string. Should contain explicit step markers or numbered reasoning. Validate that reference includes both reasoning steps and a final answer.

[TASK_DESCRIPTION]

The original problem statement or question both solutions attempt to solve

Solve for x in the equation 2x + 4 = 10. Show all steps.

Must be non-empty string. Should match the task that produced both solutions. Cross-check that [STUDENT_SOLUTION] and [REFERENCE_SOLUTION] both address this task.

[EVALUATION_CRITERIA]

Specific dimensions to assess: logical validity, step alignment, arithmetic correctness, conclusion support

logical validity, arithmetic correctness, step completeness, conclusion alignment

Must be a comma-separated list or structured array. Each criterion should be a short, evaluable label. Avoid vague criteria like 'quality' without definition.

[SCORING_RUBRIC]

The scale and rules for assigning scores to each reasoning step

1: Step is logically invalid or contradicts reference. 2: Step is partially correct but missing justification. 3: Step is correct and well-justified. 4: Step is correct, justified, and matches reference reasoning path.

Must define at least 3 score levels with descriptions. Each level must have a decision rule. Validate that rubric levels are mutually exclusive and cover the full range of possible step quality.

[OUTPUT_FORMAT]

The required structure for the evaluation report

JSON with fields: step_comparisons (array of {step_number, student_step, reference_step, score, justification}), overall_score, error_flags, final_answer_match (boolean)

Must be a valid schema definition or example. Parse as JSON schema if provided. Check that required fields include step-level comparison, overall score, and final answer match flag.

[MAX_STEPS]

Upper bound on expected reasoning steps to prevent unbounded output

10

Must be a positive integer. Use to guard against runaway step generation. If student or reference solution exceeds this, truncation or error handling should trigger before evaluation.

[TOLERANCE_CONFIG]

Rules for accepting near-matches in numeric or fuzzy comparisons

exact_match_required: true, numeric_tolerance: 0.001, allow_equivalent_expressions: true

Must be a valid JSON object or structured string. Define tolerance for numeric comparisons and whether algebraically equivalent expressions count as matches. Null allowed if task has no numeric component.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the step-by-step reasoning verification prompt into an evaluation pipeline with API calls, validation, retry logic, and human review gates.

This prompt is designed to be called programmatically as part of an automated evaluation pipeline, not as a one-off manual check. The typical harness wraps the prompt in an API call that sends both the model's reasoning trace and the reference solution, then parses the structured JSON output for downstream scoring. Because the prompt performs a step-level comparison, the harness must ensure that the reasoning trace is already extracted and formatted before this prompt runs—this is not the prompt that generates the reasoning; it is the prompt that verifies it against a known-correct reference. The harness should treat this as a synchronous evaluation step that runs after the primary model generates its answer and chain-of-thought, but before the final score is recorded in your evaluation database.

The implementation should include a validation layer that checks the JSON output against the expected schema before accepting the result. The prompt's output schema includes fields like step_comparisons (an array of objects with step_number, reference_step, model_step, match_type, and explanation), overall_alignment_score, and critical_errors (a list of step numbers where the model's logic diverges fatally from the reference). Your harness should validate that match_type is one of the allowed enum values (exact_match, logical_equivalent, missing_step, extra_step, contradiction, order_mismatch), that overall_alignment_score is a float between 0.0 and 1.0, and that critical_errors contains valid step references. If validation fails, implement a retry loop with a maximum of two additional attempts, appending the validation error message to the prompt context so the model can self-correct. Log every validation failure and retry attempt for observability. For high-stakes domains like healthcare or finance, add a human review gate that triggers when overall_alignment_score falls below 0.7 or when critical_errors is non-empty, routing the case to a review queue before the evaluation result is committed.

Model choice matters for this prompt. Use a model with strong reasoning capabilities—GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro are appropriate defaults. Avoid smaller or faster models that may struggle with the fine-grained step comparison task, as false negatives in match_type classification can undermine trust in your evaluation pipeline. Set temperature=0 to maximize determinism, and use a sufficiently high max_tokens value (at least 4096) to accommodate detailed step-by-step comparisons. The harness should also track latency and token usage per evaluation call, as this prompt can become expensive when run across large test suites. Consider batching evaluations where possible, but avoid parallel calls that exceed your rate limits—step verification is a sequential dependency in most evaluation DAGs. Finally, store the full prompt input, raw model output, validated JSON, and any human review decisions in your evaluation database so that every score is auditable and reproducible.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the exact fields, types, and validation rules for the step-by-step reasoning verification report. Use this contract to build a parser, validator, and retry logic before integrating the prompt into a production pipeline.

Field or ElementType or FormatRequiredValidation Rule

verdict

string enum: ['PASS', 'FAIL', 'PARTIAL']

Must be exactly one of the three enum values. Reject any other string.

overall_score

float between 0.0 and 1.0

Must parse as a number. Must be >= 0.0 and <= 1.0. If verdict is PASS, score must be >= 0.9. If FAIL, score must be < 0.5.

step_comparisons

array of objects

Must be a non-empty array. Each element must match the step_comparison schema below. Array length must equal the number of reference steps.

step_comparisons[].step_id

string matching reference step identifier

Must exactly match a step_id from the provided [REFERENCE_STEPS]. No missing or extra steps allowed.

step_comparisons[].match

boolean

Must be true or false. If false, a logical_error must be present.

step_comparisons[].logical_error

string or null

Required if match is false. Must describe the specific logical deviation. If match is true, must be null or absent.

step_comparisons[].evidence

string

Must contain a direct quote or precise reference from [MODEL_OUTPUT] supporting the match or mismatch claim.

critical_failure

boolean

Must be true if any logical error invalidates subsequent steps, even if the final answer matches. Otherwise false.

PRACTICAL GUARDRAILS

Common Failure Modes

Step-by-step reasoning verification fails in predictable ways. These cards cover the most common failure modes when comparing a model's reasoning trace against a reference solution, and how to guard against them before they reach production.

01

Surface-Level Agreement Masks Logical Errors

What to watch: The model's final answer matches the reference, but one or more intermediate reasoning steps contain a logical fallacy, a skipped dependency, or an unjustified leap. The verifier accepts the output because the conclusion is correct. Guardrail: Require the judge to score each reasoning step independently against the reference trace before considering the final answer. If any step is flagged as invalid or unsupported, the entire output fails regardless of the conclusion.

02

Judge Accepts Plausible-Sounding but Incorrect Reasoning

What to watch: The model generates a reasoning chain that reads fluently and uses domain terminology correctly, but contains a subtle factual error or misapplication of a rule. The LLM judge is persuaded by fluency and fails to detect the error. Guardrail: Include explicit instructions in the judge prompt to cross-check each reasoning claim against the reference step. Require the judge to cite the specific reference step that supports or contradicts each claim. Use a strict rubric that penalizes unsupported assertions even when they sound reasonable.

03

Equivalent Reasoning Paths Are Scored as Incorrect

What to watch: The model reaches the correct answer through a valid but different reasoning path than the reference. The judge marks it wrong because it doesn't match the expected step sequence. Guardrail: Instruct the judge to evaluate logical validity and factual correctness of each step, not surface-level alignment with the reference order. Allow alternative derivations as long as each step is sound and the conclusion follows. Include a tolerance rule for commutative or reordered operations.

04

Granularity Mismatch Causes False Step-Level Failures

What to watch: The reference solution breaks reasoning into 10 fine-grained steps, but the model output compresses the same logic into 3 higher-level steps. The judge reports missing steps because it cannot align the granularity levels. Guardrail: Add a pre-processing pass that normalizes both traces to a common granularity before comparison. Alternatively, instruct the judge to verify that all reference concepts are covered somewhere in the model's trace, without requiring one-to-one step alignment.

05

Reference Error Propagates Through All Evaluations

What to watch: The reference solution itself contains a logical error, a stale fact, or an incorrect assumption. Every model output that correctly identifies the error is penalized, while outputs that replicate the reference mistake pass. Guardrail: Version-lock all reference solutions and run periodic human audits on the golden dataset. Add a contradiction-detection pass that flags when the model's reasoning consistently diverges from the reference at the same step—this may indicate a reference error rather than a model failure.

06

Judge Hallucinates Step-Level Feedback

What to watch: The LLM judge generates plausible-sounding step-by-step feedback that references specific line numbers, claims, or errors that don't actually exist in the model's output. The evaluation report looks authoritative but is fabricated. Guardrail: Require the judge to quote the exact text from the model output and the reference when making a claim about an error. Run a secondary verification pass that checks whether each quoted span actually appears in the source. Flag evaluations where the judge cannot produce matching quotes.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the step-by-step reasoning judge before relying on it in production. Each criterion targets a specific failure mode in reasoning verification.

CriterionPass StandardFailure SignalTest Method

Step Alignment Accuracy

Judge correctly maps each model step to the corresponding reference step, or flags it as unmapped

Judge maps a step to the wrong reference step, or misses a clear mapping

Run against 10 hand-annotated reasoning traces with known step mappings; require >= 90% mapping accuracy

Logical Error Detection

Judge identifies at least 90% of injected logical fallacies (e.g., circular reasoning, false cause, non sequitur)

Judge marks a logically flawed step as correct, or misses an injected error

Use a golden dataset of 20 reasoning traces with 5 injected logical errors each; measure recall of known errors

Correct Step Acceptance

Judge marks correct steps as correct with <= 5% false-positive error flagging

Judge flags a valid reasoning step as erroneous when it matches the reference logic

Use the same golden dataset; measure precision of error flags against known-correct steps

Final Answer Independence

Judge identifies reasoning errors even when the final answer matches the reference

Judge passes a trace with a wrong intermediate step because the final answer is correct

Include 5 traces where the final answer matches but a middle step contains a deliberate error; require 100% detection

Missing Step Detection

Judge flags gaps where the model skipped a reasoning step present in the reference

Judge does not flag a missing inference step that the reference explicitly includes

Use 5 traces with 2 intentionally omitted steps each; require >= 80% missing-step recall

Extraneous Step Handling

Judge identifies steps that have no counterpart in the reference without penalizing the score if they are logically sound

Judge marks a valid extra step as an error, or fails to note an irrelevant tangent

Test with 5 traces containing 3 extraneous but correct steps each; verify judge labels them as extraneous, not erroneous

Ambiguity Flagging

Judge marks steps as ambiguous when the reference allows multiple valid interpretations

Judge forces a binary correct/incorrect on a step where reasonable experts would disagree

Use 5 traces with intentionally ambiguous steps reviewed by 3 human raters; judge must flag ambiguity when human agreement < 70%

Score Calibration Stability

Judge produces consistent scores across 3 repeated runs on the same trace (score variance < 0.1 on a 0-1 scale)

Judge assigns scores of 0.7, 0.4, and 0.9 to the same trace across runs

Run the same 5 traces through the judge 3 times each; measure max score delta per trace

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base template with a single reference solution and lighter validation. Remove the [REASONING_STEPS] schema requirement initially—just ask the judge to list steps and flag mismatches in free text. This lets you iterate on the comparison criteria before locking down output structure.

Watch for

  • The judge accepting superficial step alignment without checking logical validity
  • Missing step granularity guidance causing inconsistent comparisons
  • Overly strict matching that rejects equivalent reasoning paths
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.