Repository navigation
Reuse SacreBLEU tokenizers in SARI and WikiSplit - #896
Open
snygginghani wants to merge 1 commit into
Open
snygginghani wants to merge 1 commit into
snygginghani wants to merge 1 commit into
Conversation
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
SARI normalization resolves the SacreBLEU version and creates a tokenizer for each source, prediction, and reference. WikiSplit repeats the same work in its SARI calculation. Cache the two SacreBLEU tokenizer instances so both metrics can reuse the tokenizer and its existing result cache. The metric Spaces ship independently, so each keeps its own helper.
Benchmark
I used all 2,000 examples from the ASSET validation split, with the first annotator's simplification as the prediction and the other nine as references. I measured public
.compute()calls with in-memory metric instances, after warm-up, across seven alternating runs.All returned scores matched exactly on both revisions. Tested on Windows, Python 3.13.3, datasets 5.2.0 and SacreBLEU 2.6.0.
To reproduce, load the local metric at
./metrics/sarior./metrics/wiki_splitwithkeep_in_memory=True. Readdataset/asset.valid.origas sources,asset.valid.simp.0as predictions, and zipasset.valid.simp.1throughasset.valid.simp.9by row to create the references. Timemetric.compute(sources=sources, predictions=predictions, references=references).python -m pytest tests/test_text_simplification_metrics.py -qpassed both regression cases. Black, isort, flake8, andgit diff --checkpassed.AI assistance was used to prepare the patch, tests, and benchmark.