Skip to content

Reuse SacreBLEU tokenizers in SARI and WikiSplit - #896

Open
snygginghani wants to merge 1 commit into
huggingface:mainfrom
snygginghani:perf/reuse-sari-tokenizers
Open

snygginghani wants to merge 1 commit into
huggingface:mainfrom
snygginghani:perf/reuse-sari-tokenizers

Conversation

@snygginghani

Copy link
Copy Markdown

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.

Metric Before After
SARI 2,370 ms 1,457 ms
WikiSplit 4,754 ms 3,811 ms

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/sari or ./metrics/wiki_split with keep_in_memory=True. Read dataset/asset.valid.orig as sources, asset.valid.simp.0 as predictions, and zip asset.valid.simp.1 through asset.valid.simp.9 by row to create the references. Time metric.compute(sources=sources, predictions=predictions, references=references).

python -m pytest tests/test_text_simplification_metrics.py -q passed both regression cases. Black, isort, flake8, and git diff --check passed.

AI assistance was used to prepare the patch, tests, and benchmark.

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.

1 participant