Equivalence Match
Equivalence Match
Use an equivalence-match verifier when correctness can be decided deterministically from the agent’s output and task metadata. The verifier:
- Extracts the answer-bearing part of the response.
- Converts the prediction and reference to comparable representations.
- Applies a task-appropriate equality or similarity rule.
- Maps the result to a reward.
This pattern is usually faster, cheaper, and more reproducible than an LLM-as-Judge. The main design risk is choosing an equivalence rule that is either too strict and rejects valid answers or too permissive and accepts wrong ones.
← Back to Verification PatternsStart With the Narrowest Correct Rule
Prefer the simplest rule that captures all valid answers for the task:
- Exact match for closed answer sets such as multiple-choice letters.
- Normalized match when formatting differences are irrelevant.
- Numeric tolerance for floating-point results.
- Symbolic equivalence when different mathematical forms can represent the same value.
- Continuous similarity only when correctness is naturally graded rather than binary.
Keep extraction separate from comparison. This makes failures observable: you can distinguish “no answer was extracted” from “an answer was extracted but did not match.”
Exact String Match
Exact matching is appropriate after extraction has reduced the output to a canonical value, such as one allowed multiple-choice letter. Do not compare the entire free-form response when reasoning or formatting may vary.
This example is condensed from mcqa:
Validate extracted values against the allowed answer set. Otherwise an overly broad regular expression can turn incidental prose into a prediction.
Examples:
mcqasupports boxed,Answer:, Markdown-aware, and dataset-supplied extraction expressions before exact letter comparison.gpqa_diamondextracts a choice and compares it with the reference answer.circle_countextracts a discrete count and assigns a binary reward.
Normalized Text Match
Normalize only differences that the task declares irrelevant. Common operations include lowercasing, removing punctuation or articles, canonicalizing Unicode, and collapsing whitespace.
This SQuAD-style normalization is condensed from hotpotqa_qa:
Store legitimate aliases as reference data or generate them with explicit, reviewable rules. Avoid open-ended “synonym” replacement: it can silently make semantically different answers equal.
Examples:
hotpotqa_qaparses an answer from JSON, applies SQuAD-style normalization, and supports curated surface-form alternatives.equivalence_rulelowercases and collapses whitespace before exact or fuzzy comparison.ruleruses task-specific deterministic answer matching for long-context retrieval tasks.
Numeric Match With Tolerance
Floating-point strings can differ while representing effectively the same result. First try normalized exact equality, then parse finite numeric values and compare them with an explicit relative and absolute tolerance.
This example follows math_with_code:
Choose tolerances from the task’s units and expected numerical precision, not as a universal constant. Reject non-finite values unless the benchmark explicitly permits them.
Examples:
math_with_codenormalizes math delimiters, checks exact equality, then applies a relative numeric tolerance.litmus_agentsupportsisclose, absolute-window, and relative-window numeric grading rules.
Regex and Boxed Extraction
Many benchmarks ask the model to mark its final answer with \boxed{...} or Answer:. Extraction is not itself verification; it creates the candidate that a later comparison rule scores.
Use the last final-answer marker so intermediate reasoning does not win. For boxed LaTeX, track brace depth instead of using a regular expression that stops at the first nested }:
Examples:
mcqahandles nested boxed answers,Answer:payloads, and custom extraction regexes.math_with_codesearches the final assistant response and tool output for the last boxed answer.format_verificationchecks task-specific response formatting.
Do not use eval() to parse model-generated answers. Prefer constrained regular expressions, json.loads(), or a domain parser.
Symbolic Equivalence
String equality is insufficient for mathematics: x(x + 1) and x^2 + x are different strings but equivalent expressions. Use a maintained parser and symbolic verifier with time and concurrency limits.
math_with_judge uses the math-verify library, which parses expressions and uses symbolic math checks:
Symbolic simplification can be expensive or hang on adversarial expressions. Run it with a timeout and bounded concurrency. Treat parser failure separately from a valid but non-equivalent expression.
Examples:
math_with_judgeruns library verification in a killable subprocess and optionally falls back to an LLM judge.imo_proofbench_judgecombines deterministic math handling with proof-oriented judging.
Fuzzy and Continuous Similarity
Use continuous similarity when partial overlap is meaningful, such as translation or long-form retrieval. Return a score in [0, 1] so it can be used directly as a dense reward.
This example follows mrcr:
Different metrics encode different notions of similarity. Pin metric versions and tokenizers, and do not compare scores produced with different configurations.
Examples:
mrcrusesSequenceMatcher.ratio()after enforcing a required prefix.equivalence_ruleoffers normalized sequence similarity and a weighted prefix variant.wmt_translationcomputes sentence chrF and spBLEU, using normalized chrF as the reward.
Structured Output Match
Parse structured output before comparing it. Depending on the task, correctness can mean either:
- Value equality: the parsed object must equal a reference object.
- Shape validity: the parsed object must satisfy a schema, even when many values are valid.
This grid-equality example is condensed from arc_agi:
For schema-only tasks, parse the response and validate the resulting object:
Examples:
arc_agiextracts a JSON grid, validates integer cells, and compares the nested lists.structured_outputsparses JSON, YAML, XML, TOML, CSV, or tool arguments and validates them against a strict OpenAPI schema.
Instruction and Constraint Checking
Some tasks define correctness as satisfying a set of programmatic constraints rather than matching one answer. Build one checker per instruction, retain each boolean result for diagnostics, and then choose binary or fractional aggregation.
This example is condensed from instruction_following:
Examples:
instruction_followingruns registry-backed checks and supports all-or-nothing or fractional reward.ifbenchrecords strict and loose instruction checks and supports binary or fractional grading.
Implement the Pattern in verify()
A resources server should return both the reward and enough structured evidence to debug it:
Keep the reference answer in typed request metadata, not in the prompt text alone. Preserve the extracted prediction and any component scores in the verify response so reward profiling can reveal extraction failures, overly strict normalization, and partial-credit behavior.
Test the Decision Boundary
For every equivalence verifier, add tests for:
- A canonical correct answer.
- A valid alternative representation.
- A near miss that must remain incorrect.
- Missing, malformed, and ambiguous answers.
- Multiple final-answer markers.
- Extreme numeric values or deeply nested structured input where applicable.
- Empty output and unexpected response item types.
The most important tests sit at the boundary between accepted variation and false positives. A verifier that accepts the happy path but over-rewards near misses will produce misleading evaluation metrics and a weak training signal.
Related Topics
- Build Verifiers — resources server interfaces and verifier responsibilities
- Verification Patterns — choose another scoring pattern
- LLM-as-Judge — evaluate semantic or rubric-based criteria that deterministic rules cannot express reliably
- Multi-Reward Verification — expose several component scores from one verifier