Repository navigation
fix(officeqa): keep a numeric 0 gold answer when loading JSON splits - #403
Open
Lanre Shittu (Shizoqua) wants to merge 1 commit into
Open
Lanre Shittu (Shizoqua) wants to merge 1 commit into
Lanre Shittu (Shizoqua) wants to merge 1 commit into
Conversation
_normalize_row read the gold answer with
str(row.get("ground_truth") or row.get("answer") or ""). A JSON split
can store a numeric answer, and 0 or 0.0 is falsy, so it was skipped:
the item loaded with an empty ground_truth and no answers, and a model
answering "0" scored EM 0 and F1 0.
Take the first field that is present and not blank instead. String
values, the "answer" fallback and items with no gold answer behave as
before; a whitespace-only ground_truth now also falls back to "answer".
This branch has not been deployed
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.
Summary
Fixes #400.
The OfficeQA loader read the gold answer with
str(row.get("ground_truth") or row.get("answer") or ""). In a JSON split, a numeric gold answer of0or0.0is falsy, so it was skipped: the item loaded with an emptyground_truthand noanswers, and a model answering0scored EM 0 and F1 0. The loader now takes the first field that is present and not blank.User impact: OfficeQA answers are mostly numbers from Treasury tables, so
0is a plausible gold value. Those items gave zero reward for the correct answer and counted as misses in reported scores.Proof: the regression tests fail on upstream
45f65caand pass with this change.Root cause
_normalize_row()inskillopt/envs/officeqa/dataloader.pychainedoracrossground_truthandanswer.ortreats0and0.0as missing. CSV splits are not affected because CSV values are strings, but JSON splits keep numeric types.Changes
_first_text(row, *keys)helper returns the first value that is notNoneand not blank, as stripped text._normalize_row()uses it for the gold answer.answerfallback, and items with no gold answer behave as before. A whitespace-onlyground_truthnow also falls back toanswerinstead of producing an empty gold.tests/test_officeqa_dataloader.py, loading real JSON split files throughOfficeQADataLoader.load_split_items().Reproduction
Before:
q1 '' [] 0.0After:
q1 '0' ['0'] 1.0Testing
python -m pytest tests/test_officeqa_dataloader.py -q: on upstream45f65ca, 3 failed (assert '' == '0'and similar) and 2 passed; with the fix, 5 passed.tests/test_officeqa_*.pyandtests/test_benchmark_task_output_paths.py): 112 passed.python -m pytest -q: 2221 passed, 12 skipped, 4 xfailed.python -m ruff checkon the changed files: oneF401for an unusedimport osthat is unchanged frommain; the new test file is clean.python -m mkdocs build --strict: passed.Risk and compatibility
Only JSON items whose gold answer is numeric zero, or whose
ground_truthis whitespace-only, load differently. No backend, config key, file format or CLI change. A gold value of0.0now loads as"0.0"; whether0and0.0should match is left to the evaluator's existing normalization.