Skip to content

Commit 374cabb

Browse files
T5 Teamt5-copybara
authored andcommitted
Expose use_effective_order flag for bleu score computation for shorter sentences
PiperOrigin-RevId: 642433884
1 parent 69cf3b5 commit 374cabb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

t5/evaluation/metrics.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@
4545
ModelOutputType = seqio.metrics.ModelOutputType
4646

4747

48-
def bleu(targets, predictions, tokenizer="intl"):
48+
def bleu(targets, predictions, tokenizer="intl", use_effective_order=False):
4949
"""Computes BLEU score.
5050
5151
Args:
5252
targets: list of strings or list of list of strings if multiple references
5353
are present.
5454
predictions: list of strings
5555
tokenizer: tokenizer option for corpus_bleu
56+
use_effective_order: whether to use effective order when computing BLEU.
5657
5758
Returns:
5859
bleu_score across all targets and predictions
@@ -69,7 +70,7 @@ def bleu(targets, predictions, tokenizer="intl"):
6970
force=False,
7071
lowercase=False,
7172
tokenize=tokenizer,
72-
use_effective_order=False)
73+
use_effective_order=use_effective_order)
7374
return {"bleu": bleu_score.score}
7475

7576

0 commit comments

Comments
 (0)