Commit 83252575 authored by Jonathan Tow's avatar Jonathan Tow
Browse files

Add newline separator for correct `rougeLsum`

parent 61b14994
...@@ -399,9 +399,15 @@ class TruthfulQAGeneration(Task): ...@@ -399,9 +399,15 @@ class TruthfulQAGeneration(Task):
""" """
rouge_types = ["rouge1", "rouge2", "rougeLsum"] rouge_types = ["rouge1", "rouge2", "rougeLsum"]
scorer = rouge_scorer.RougeScorer(rouge_types) scorer = rouge_scorer.RougeScorer(rouge_types)
# Add newlines between sentences to correctly compute `rougeLsum`.
def _prepare_summary(summary):
summary = summary.replace(" . ", ".\n")
return summary
# Accumulate confidence intervals. # Accumulate confidence intervals.
aggregator = scoring.BootstrapAggregator() aggregator = scoring.BootstrapAggregator()
for ref, pred in zip(refs, preds): for ref, pred in zip(refs, preds):
ref = _prepare_summary(ref)
pred = _prepare_summary(pred)
aggregator.add_scores(scorer.score(ref, pred)) aggregator.add_scores(scorer.score(ref, pred))
result = aggregator.aggregate() result = aggregator.aggregate()
return {type: result[type].mid.fmeasure*100 for type in rouge_types} return {type: result[type].mid.fmeasure*100 for type in rouge_types}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment