[Fix] Fix OlympiadBench grading of factored answers - #2593
Open
mkzung wants to merge 1 commit into
Open
Conversation
is_interval only inspects the first and last character, so a factored product such as (x-1)(x+1) is routed to interval_equal. Stripping the outer brackets leaves the fragment x-1)(x+1, comparing it raises, and the handler abandoned the comparison there. The numerical, expression and equation checks that follow do prove these answers equal, so the handler falls through to them like the other three.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
MathJudger.is_equalruns four equivalence tests in sequence: interval, numerical,expression, equation. The last three swallow a failure and fall through to the next
one. The interval test returns False, which ends the comparison.
is_intervalclassifies a string by its first and last character only, so a factoredproduct such as
(x-1)(x+1)is taken for an interval.interval_equalstrips theouter brackets, leaving the fragment
x-1)(x+1, and comparing it raises insidecompare_two_interval:expression_equalreturns a sympyRelationalwhen thedifference is still symbolic, and
if not ...cannot evaluate it. The exception thenends the whole comparison, so the expression test that proves these two answers
equal is never reached.
With sympy 1.14.0,
OlympiadBenchEvaluator.scorereports 0.0 accuracy for three suchprediction/reference pairs:
Tightening
is_intervalso that a factored product is not classified as an intervalwould keep these answers off the interval path in the first place. This PR does the
smaller thing: a failed interval test no longer ends the comparison.
Modification
is_equalfalls through to the remaining tests, as thenumerical, expression and equation handlers already do.
tests/datasets/test_olympiadbench.pycovers a factored product against itsexpansion and against a wrong expansion, and pins interval comparison for equal,
unequal and mixed-bracket bounds.
BC-breaking (Optional)
No. An answer that graded correct still grades correct; the change can only add a
later test, never remove one.
A sweep of 26 bracket-delimited pairs through
MathJudger.judgemoves three verdicts,all of them false negatives:
The other 23 are unchanged, including
(1,2)vs(1,3),[0,1]vs(0,1),(-\infty,0)vs(-\infty,0]and(x-1)(x+1)vs(x^2+1), which stay False, and(0,\infty)vs(0,+\infty)and(\frac{1}{2},1)vs(0.5,1), which stay True.Use cases (Optional)
Not applicable.
Tests
pytest tests/datasets/test_olympiadbench.py -q— 2 passed. Onmain,test_factored_product_equals_expanded_formfails withAssertionError: False is not trueand the interval test already passes.pytest tests/datasets tests/openicl tests/utils tests/evaluator --ignore=tests/datasets/test_local_datasets.py -q— 3 failed, 162 passed, 2 skipped.The same three
test_livecodebench_evaluatorcases fail unchanged onmain(macOS
multiprocessingspawn, unrelated to this PR).pre-commit run --files opencompass/datasets/OlympiadBench.py tests/datasets/test_olympiadbench.py— flake8, isort, yapf and codespell pass.Checklist
Before PR:
After PR: