Skip to content

Commit

Permalink
Disable logging all rouge scores calculated by default.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 574892306
  • Loading branch information
rhofour authored and t5-copybara committed Oct 19, 2023
1 parent dd1cede commit 9b0e79c
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions t5/evaluation/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,16 @@ def rouge(
targets,
predictions,
score_keys=("rouge1", "rouge2", "rougeLsum"),
verbose=False,
**kwargs,
):
"""Computes rouge score nondeterministically using the bootstrap.
Args:
targets: list of strings
predictions: list of strings
targets: list of strings.
predictions: list of strings.
score_keys: list of strings with the keys to compute.
verbose: whether to enable additional logging.
**kwargs: additional keyword arguments for RougeScorer.
Returns:
Expand All @@ -106,14 +108,15 @@ def rouge(
prediction = _prepare_summary_rouge(prediction)
aggregator.add_scores(scorer.score(target=target, prediction=prediction))
result = aggregator.aggregate()
for key in score_keys:
logging.info(
"%s = %.2f, 95%% confidence [%.2f, %.2f]",
key,
result[key].mid.fmeasure*100,
result[key].low.fmeasure*100,
result[key].high.fmeasure*100,
)
if verbose:
for key in score_keys:
logging.info(
"%s = %.2f, 95%% confidence [%.2f, %.2f]",
key,
result[key].mid.fmeasure*100,
result[key].low.fmeasure*100,
result[key].high.fmeasure*100,
)
return {key: result[key].mid.fmeasure*100 for key in score_keys}


Expand Down

0 comments on commit 9b0e79c

Please sign in to comment.