@@ -304,25 +304,33 @@ class RougeN(clu_metrics.Metric):
304304 r"""Computes macro-averaged ROUGE-N recall, precision, and F1-score.
305305
306306 This metric first calculates ROUGE-N precision, recall, and F1-score for each
307- individual prediction compared against its single corresponding reference.
308- These per-instance precision, recall and F1-scores are then averaged across
309- all instances in the dataset/batch.
307+ individual prediction compared against its single corresponding reference. ROUGE-N
308+ scores are based on the number of overlapping n-grams (sequences of n words)
309+ between the prediction and the reference text. These per-instance precision,
310+ recall, and F1-scores are then averaged across all instances in the dataset/batch.
310311
311- Accumulation for Macro-Average:
312- - total_precision = sum of all precision values.
313- - total_recall = sum of all instance_recall values.
314- - total_f1 = sum of all f1 values.
315- - num_examples = count of prediction-reference pairs.
312+ How ROUGE-N scores are calculated for each individual prediction-reference pair:
313+
314+ .. math::
315+ \text{Precision} = \frac{N_o}{N_p}
316+ .. math::
317+ \text{Recall} = \frac{N_o}{N_r}
318+ .. math::
319+ \text{F1} = 2 \times \frac{\text{Precision} \times \text{Recall}}{\text{Precision} + \text{Recall}}
320+ where:
321+ - :math:`N_o` be the number of n-grams that overlap between the prediction and the reference.
322+ - :math:`N_p` be the total number of n-grams in the prediction.
323+ - :math:`N_r` be the total number of n-grams in the reference.
316324
317325 Final Macro-Averaged Metrics:
326+
318327 .. math::
319328 \text{MacroAvgPrecision} =
320329 \frac{\text{total_precision}}{\text{num_examples}}
321330 .. math::
322331 \text{MacroAvgRecall} = \frac{\text{total_recall}}{\text{num_examples}}
323332 .. math::
324- \text{MacroAvgF1} = 2 \cdot \frac{\text{MacroAvgPrecision} \cdot
325- \text{MacroAvgRecall}}{\text{MacroAvgPrecision} + \text{MacroAvgRecall}}
333+ \text{MacroAvgF1} = \frac{\text{total_f1}}{\text{num_examples}}
326334
327335 Attributes:
328336 order: The specific 'N' in ROUGE-N (e.g., 1 for ROUGE-1, 2 for ROUGE-2).
0 commit comments