Skip to content

Handle short and empty predictions in NIST MT - #904

Open
snygginghani wants to merge 1 commit into
huggingface:mainfrom
snygginghani:fix/nist-short-predictions
Open

snygginghani wants to merge 1 commit into
huggingface:mainfrom
snygginghani:fix/nist-short-predictions

Conversation

@snygginghani

Copy link
Copy Markdown

The NIST MT default evaluates up to 5-grams. If every tokenized hypothesis is shorter, NLTK divides by zero for the unavailable higher orders. Score only the orders present in at least one hypothesis. A batch made entirely of blank predictions scores zero.

I reproduced the failure through the public metric with the short hypothesis "Ende gut" and the reference "Ende gut, alles gut." from a CoVoST2 German translation. After the change the default returns 0.012855860576534536, the same score as explicitly setting n=2. The published longer multi-reference example remains unchanged at 3.3709935957649324.

Both new regressions failed on main and passed with the fix on NLTK 3.10.4. Black, isort, flake8 and git diff --check passed.

Prepared with AI assistance.

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