Skip to content

fix(metrics): gpqa CoT fallback answer regex uses escaped brackets (never matches)#4323

Open
WatchTree-19 wants to merge 1 commit into
stanford-crfm:mainfrom
WatchTree-19:fix-gpqa-cot-answer-regex
Open

fix(metrics): gpqa CoT fallback answer regex uses escaped brackets (never matches)#4323
WatchTree-19 wants to merge 1 commit into
stanford-crfm:mainfrom
WatchTree-19:fix-gpqa-cot-answer-regex

Conversation

@WatchTree-19

Copy link
Copy Markdown

problem

in src/helm/benchmark/metrics/gpqa_chain_of_thought_metric.py, the fallback answer-extraction regex is written with escaped brackets:

match = re.search(r"\.*\[aA\]nswer:\s*\(?([A-J])\)?", output_text)

\[aA\] matches the literal characters [aA], not the intended character class [aA] (match a or A). so this branch only ever matches the impossible literal string "[aA]nswer:" and never a real output like "Answer: B". it's effectively dead code: when a model answers in the Answer: X format (a common deviation from the requested The correct answer is (X)), the letter is not extracted and the response is scored as wrong (chain_of_thought_correctness = 0).

this metric is wired into capabilities_run_specs.py for both gpqa and mmlu_pro chain-of-thought run specs.

fix

-    match = re.search(r"\.*\[aA\]nswer:\s*\(?([A-J])\)?", output_text)
+    match = re.search(r"\.*[aA]nswer:\s*\(?([A-J])\)?", output_text)

still satisfies the original [answer: F] example (\.* matches the [, [aA]nswer: matches answer:).

test

added test_gpqa_chain_of_thought_metric.py. against the current code, Answer: C / The answer: B / answer: E / ...Answer: D / [answer: F] all extract None (fail); with the fix they extract the correct letter. the primary The correct answer is (X) path (handled by the first regex) and the no-match case are unchanged. flake8 + black clean (line-length 120).

found by reading the metric. this only fixes a fallback branch that currently never fires, so it doesn't change any already-working extraction.

extract_answer's second regex was written \[aA\]nswer: (literal brackets)
instead of the [aA]nswer: character class, so it never matched real
'Answer: X' outputs and correct GPQA/MMLU-Pro CoT answers were scored wrong. +test.

Signed-off-by: WatchTree-19 <119982314+WatchTree-19@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant