Repository navigation
test(docvqa): add unit tests for the ANLS evaluator - #380
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
skillopt/envs/docvqa/evaluator.py scores every DocVQA rollout (soft is the ANLS value and hard is ANLS >= 0.999) but had no direct tests. Cover the metric as defined by Biten et al. (2019): Levenshtein distance on known pairs, 1 - NL below the 0.5 threshold and 0 at or above it (including the exact NL = 0.5 boundary), the maximum over gold answers in any order, case and whitespace normalization, empty answers, the gold answer shapes the loader accepts (lists, JSON and Python literal strings, dicts, lists of dicts), and <answer> tag extraction. No runtime code changes.
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
Adds
tests/test_docvqa_evaluator.py, direct unit tests forskillopt/envs/docvqa/evaluator.py. The evaluator scores every DocVQA rollout (softis the ANLS value andhardisanls >= 0.999inrollout.py) but had no tests of its own, so a regression in the metric would only show up as a silent change in benchmark numbers.No runtime code changes.
What the tests cover
The tests follow the ANLS definition from Biten et al. (2019): for each gold answer, NL is the Levenshtein distance divided by the length of the longer string; the score is
1 - NLwhenNL < 0.5and0otherwise; the item score is the maximum over gold answers.kitten/sitting= 3,flaw/lawn= 2, identical and empty strings), in both argument orders.NL = 0.5boundary (abcdvsab) scores 0, as the definition requires.abcdvsabcescores 0.75 and stays below thehardcutoff used by the rollout.answersorground_truth, lists of dicts withtext,answerorvalue, plain strings, numbers,Noneand empty values.<answer>extraction: case-insensitive tags, the last tag wins, and the last non-empty line is the fallback.Testing
python -m pytest tests/test_docvqa_evaluator.py -q: 32 passed.python -m pytest -q: 2101 passed, 12 skipped, 4 xfailed (32 more thanmainat6ee29a0).python -m ruff check tests/test_docvqa_evaluator.pyandpython -m ruff format --check tests/test_docvqa_evaluator.py: clean.python -m mkdocs build --strict: passed.To check that the tests catch real regressions, I made each of these changes to the evaluator in turn, ran the suite, and reverted. Every one makes at least one test fail:
>=changed to><answer>tag used instead of lastRisk and compatibility
Test-only change plus a CHANGELOG line under Unreleased / Tests. No dependencies added; the tests are pure Python and run without network access.