Skip to content

feat(verifiers): enforce math and STEM answer-format contracts - #6525

Draft
Kipok wants to merge 5 commits into
mainfrom
codex/math-template-contract
Draft

Kipok wants to merge 5 commits into
mainfrom
codex/math-template-contract

Conversation

@Kipok

@Kipok Kipok commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add optional per-task answer_format_regex contracts to math_with_judge and stem_judge. Templates can require an answer tag or line while keeping correctness grading in the existing resources server. For example, a task requiring only <answer>2</answer> receives zero for The answer is <answer>2</answer>, even if the answer is correct.

The regex must match the entire final assistant text and contain a nonempty named answer capture. A mismatch returns zero without calling a correctness checker. Valid matches send only the captured answer to the existing grader and retain the original response. answer_format_valid distinguishes format compliance from correctness. Both task-data schemas and verifier requests reject malformed regexes and missing named captures.

STEM applies the contract to answer and rubric rows, overriding boxed/free selection and boxed_judge_input. Its truncation and empty-answer gates run first; max_answer_chars applies to the capture. Saved results preserve their original boxed/free setting and regex for reverification. Rows without a regex retain existing behavior and omit the new optional output fields.

Math preserves the complete capture for judge fallback. Captures with nested boxes or unmatched braces bypass symbolic grading to avoid grading a fragment; without a judge they receive zero. PolyMath, UGPhysics, and finance task schemas explicitly reject this optional setting until their own verifier paths implement it.

This extends the STEM row schema and gating behavior introduced in #6518. No separate issue is needed for this focused, optional environment feature. No changes to judge prompts or training preparation. Rows without a contract retain their existing scoring paths.

Validation

  • Math component: 156 tests passed; gym env test --resources-server math_with_judge +should_validate_data=true passed example-data validation.
  • STEM component: 142 tests passed; gym env test --resources-server stem_judge +should_validate_data=true passed example-data validation.
  • Tests cover malformed contracts, empty and unmatched captures, forbidden prefix/suffix text, repeated tags, valid and incorrect answers, nested LaTeX, reasoning exclusion, split text blocks, rubric grading, capture length limits, saved-result reverification, judge-correct captures in majority/no-answer metrics, and unchanged no-contract behavior.
  • Repository-wide pre-commit run --all-files passed, including package layering and guardword checks.
  • STEM live smoke with Kimi K3.1: valid answer and rubric rows received reward 1; a correct answer in the wrong format received 0 with no judge call.
  • Math live smoke with Kimi K3.1: valid answer received 1; wrong format received 0 without grading; a nested-box fraction reached the judge intact and was correctly rejected against reference 1. A final smoke accepted the same fraction against 0.5 and retained its full capture for metrics. Policy and judge response model IDs were verified as nvidia/moonshotai/kimi-k3.1-pro.
  • PolyMath and UGPhysics existing suites: 33 tests passed.
  • Independent local review using the protected-main rubric: SHIP, three completed passes, no open findings, candidate ed6e351734ae4cea07689800c016ff73383675d0. Review was static, with test and live rollout evidence inspected; it does not replace human review or hosted CI.

Compatibility

The regex is opt-in task configuration. Template authors must encode permitted whitespace, surrounding text, and answer cardinality in the pattern. The syntax is Python re; patterns should be simple and bounded. Existing datasets are not migrated automatically. Regex format failures cannot be rescued by a judge.

@copy-pr-bot

copy-pr-bot Bot commented Nov 20, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@Kipok Kipok added area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers feature New capabilities, enhancements, or enablement work labels Nov 20, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the risk:mid Autobot PR risk: mid label Nov 20, 2026
@Kipok Kipok changed the title feat(math): enforce per-task final-answer format contracts feat(verifiers): enforce math and STEM answer-format contracts Nov 21, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added risk:high Autobot PR risk: high and removed risk:mid Autobot PR risk: mid labels Nov 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers feature New capabilities, enhancements, or enablement work risk:high Autobot PR risk: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants