rouge¶
-
class
RougeL
(trans_func=None, vocab=None, gamma=1.2, name='rouge-l', *args, **kwargs)[source]¶ Bases:
paddle.metric.metrics.Metric
Rouge-L is Recall-Oriented Understudy for Gisting Evaluation based on Longest Common Subsequence (LCS). Longest common subsequence problem takes into account sentence level structure similarity naturally and identifies longest co-occurring in sequence n-grams automatically.
\[ \begin{align}\begin{aligned}R_{LCS} & = \frac{LCS(C,S)}{len(S)}\\P_{LCS} & = \frac{LCS(C,S)}{len(C)}\\F_{LCS} & = \frac{(1 + \gamma^2)R_{LCS}P_{LCS}}}{R_{LCS} + \gamma^2{R_{LCS}}\end{aligned}\end{align} \]where
C
is the candidate sentence, and ‘S’ is the refrence sentence.- Parameters
gamma (float) – A hyperparameter to decide the weight of recall. Default: 1.2.
- Examples:(TODO: liujiaqi)
Using as a general evaluation object.
Using as an instance of
paddle.metric.Metric
.
-
add_inst
(cand, ref_list)[source]¶ Update the states based on the a pair of candidate and references.
- Parameters
cand (str) – The candidate sentence generated by model.
ref_list (list) – List of ground truth sentences.
-
update
(output, label, seq_mask=None)[source]¶ Update states for metric
Inputs of
update
is the outputs ofMetric.compute
, ifcompute
is not defined, the inputs ofupdate
will be flatten arguments of output of mode and label from data:update(output1, output2, ..., label1, label2,...)
see
Metric.compute
-
class
RougeLForDuReader
(alpha=1.0, beta=1.0, gamma=1.2)[source]¶ Bases:
paddlenlp.metrics.rouge.RougeL
Rouge-L metric with bonus for DuReader contest.
Please refer to `DuReader Homepage<https://ai.baidu.com//broad/subordinate?dataset=dureader>`_ for more details.