Skip to content

fix(officeqa): match equal numbers written with different trailing zeros - #461

Open
Lanre Shittu (Shizoqua) wants to merge 1 commit into
microsoft:mainfrom
Shizoqua:fix/officeqa-equal-numbers
Open

Lanre Shittu (Shizoqua) wants to merge 1 commit into
microsoft:mainfrom
Shizoqua:fix/officeqa-equal-numbers

Conversation

@Shizoqua

Copy link
Copy Markdown
Contributor

Summary

normalize_answer kept decimal tokens as text, so $1,234.00 did not match a gold answer of 1234, nor 5.20 match 5.2, 12.50% match 12.5% or .5 match 0.5. OfficeQA answers are mostly figures from financial tables, so a correct answer scored 0 on both EM and F1.

Changes

  • skillopt/envs/officeqa/evaluator.py: new _canonical_number() writes a decimal token one way: trailing zeros in the fraction are dropped (and the point if nothing is left), and an empty or zero-padded whole part becomes 0. A sign and a trailing % are kept. normalize_answer applies it to each token as its last step.
  • Integers and non-numeric tokens are unchanged, and numbers that differ still differ.
  • CHANGELOG.md: entry under Fixed.

Tests

tests/test_officeqa_evaluator.py:

  • $1,234.00/1234, 5.20/5.2, 12.50%/12.5%, .5/0.5, -.5/-0.5 and 1,234.50 million/1234.5 now match on EM and F1
  • 5.02/5.2, 1234.01/1234, 50/5 and 0.05/0.5 still do not match

The existing period, decimal-point and sign tests pass unchanged. The new matching tests fail on main and pass with the fix. Full suite: 2439 passed, 12 skipped, 4 xfailed. ruff format --check passes on both files, and ruff check reports only the import-sort note that is already on main.

Fixes #458

normalize_answer kept decimal tokens as text, so "$1,234.00" did not
match a gold answer of "1234", nor "5.20" match "5.2", "12.50%" match
"12.5%" or ".5" match "0.5". OfficeQA answers are mostly figures from
financial tables, so a correct answer scored 0 on both EM and F1.

Write each decimal token one way after normalization: drop trailing
zeros from the fraction (and the point if none remain) and use "0" for
an empty or zero-padded whole part. Integers and different numbers are
left as they were.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OfficeQA scores equal numbers written with different trailing zeros as wrong

1 participant