Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to calculate the BLEU score? #108

Open
sauravtii opened this issue Mar 11, 2023 · 1 comment
Open

How to calculate the BLEU score? #108

sauravtii opened this issue Mar 11, 2023 · 1 comment

Comments

@sauravtii
Copy link

Hi, how to calculate the BLEU score for the German-English translation model developed in the article?

@sdelahaies
Copy link

Hi,
you can use the library torchmetrics and its BLEUscore

install the package

pip install torchmetrics

load the function

from torchmetrics.functional import bleu_score

and then add the following lines at the end of the check_outputs function

target = [" ".join(tgt_tokens).replace("\n", "")]
preds = [model_txt.replace("\n", "")]
print("BLEU score:", bleu_score(preds, target))

to display the BLEUscore on the examples.

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

No branches or pull requests

2 participants