Skip to content

Commit

Permalink
Expose use_effective_order flag for bleu score computation for shorte…
Browse files Browse the repository at this point in the history
…r sentences

PiperOrigin-RevId: 642433884
  • Loading branch information
T5 Team authored and t5-copybara committed Jun 11, 2024
1 parent 69cf3b5 commit 50ab2a3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions t5/evaluation/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@
ModelOutputType = seqio.metrics.ModelOutputType


def bleu(targets, predictions, tokenizer="intl"):
def bleu(targets, predictions, tokenizer="intl", use_effective_order=False):
"""Computes BLEU score.
Args:
targets: list of strings or list of list of strings if multiple references
are present.
predictions: list of strings
tokenizer: tokenizer option for corpus_bleu
use_effective_order: whether to use effective order when computing BLEU.
Returns:
bleu_score across all targets and predictions
Expand All @@ -69,7 +70,7 @@ def bleu(targets, predictions, tokenizer="intl"):
force=False,
lowercase=False,
tokenize=tokenizer,
use_effective_order=False)
use_effective_order=use_effective_order)
return {"bleu": bleu_score.score}


Expand Down

0 comments on commit 50ab2a3

Please sign in to comment.