Error: RuntimeError: Empty or `None` reference sentence found


I’m trying to test a technic which involve long segments to translate. This imply having much longer segments than usual.

Upon training, I’m getting this error:

RuntimeError: Empty or `None` reference sentence found.

The error is coming from the bleu score calculation code, because the infer generated a blank line (although all my option are turned on.)

I have 2 options, I guess:

  1. Do a pull request in order to make sure there are no call with empty string, but it remain to be seen has what to use in that case for the calculation of the bleu score? ?

  2. try to change the step where the bleu score is calculated. Most likely, there are no translation, because the model isn’t trained enough to generate a translation for a very “specific case”.

Any thoughts?

Best regards,


Ideally SacreBLEU should handle empty lines nicely. This is an open issue: