nzhao721's picture
Add the deterministic grader code
62831c3 verified
|
Raw History Blame Contribute Delete
1.71 kB

Deterministic grader

The rule grader behind the rule_* fields in grades/. The LLM judge's prompt is grades/judge_prompt.md.

File What it does
grader/math_equiv.py the grader: first_answer takes the first answer field of a sample (in the open condition, after ####, Answer: or The answer is; in the direct condition, the first line), and equivalent compares it with the full gold: plain numbers exactly as fractions (commas, a dollar sign, a percent sign and a unit word are ignored), anything else with math-verify, and prose never counts
grader/test_math_equiv.py regression cases (python grader/test_math_equiv.py)
grader/orig/ the experiment's original scorer and answer parser, which math_equiv.py imports
score_samples.py scores a samples file against an evaluation config: Pass@8, PassRatio@8 and maj@8 overall and by type, plus the share of samples that state an answer and that hit the length cap
score_parallel.py the same, with each distinct (gold, answer) pair graded in worker processes and a 20-second limit per pair (a pair over the limit counts as wrong); this is the version that produced the released grades

Requirements: Python 3.10 or later with math-verify 0.9.0 (which brings sympy 1.14.0, latex2sympy2_extended 1.11.0 and antlr4-python3-runtime 4.13.2).

Example, reproducing the rule grades for the complete arm on the GSM8K test set under the open condition:

python score_parallel.py samples/gsm8k_test/open/complete.jsonl data/gsm8k_test.jsonl --out complete_scored.jsonl --mode open

This prints Pass@8 16.45% and PassRatio@8 3.65%, as in grades/gsm8k_test/open/complete.jsonl.