什么是 ROUGE 评价指标?
ROUGE(Recall-Oriented Understudy for Gisting Evaluation) 是一类用于 自动摘要评估 的评价指标,常用于衡量机器生成文本(如自动摘要、机器翻译等)与人工参考文本(如人工摘要、参考翻译)的相似度。ROUGE 主要关注 召回率(recall),因此它的计算是基于 生成文本与参考文本之间的重叠。
ROUGE 常用的变体包括 ROUGE-N, ROUGE-L, ROUGE-W, ROUGE-S 等,其中最常见的是 ROUGE-N 和 ROUGE-L。
ROUGE 主要的子指标
-
ROUGE-N:基于 n-gram 重叠的评价指标。
- ROUGE-1:计算单个词的重叠(即 unigrams)。
- ROUGE-2:计算双词组(bigrams)的重叠。
公式:
ROUGE-N = ∑ n-gram i ∈ generated count of n-gram i ∩ count of n-gram i in reference ∑ n-gram i ∈ generated count of n-gram i \text{ROUGE-N} = \frac{\sum_{\text{n-gram}_i \in \text{generated}} \text{count of n-gram}_i \cap \text{count of n-gram}_i \text{in reference}}{\sum_{\text{n-gram}_i \in \text{generated}} \text{count of n-gram}_i} ROUGE-N=∑n-grami∈generatedcount of n-grami∑n-grami∈generatedcount of n-grami∩count of n-gramiin reference
即:计算生成文本中与参考文本中出现的 n-gram 重叠的比率。 -
ROUGE-L:基于 最长公共子序列(LCS, Longest Common Subsequence)来计算文本之间的相似度,能够捕捉 词序信息。
公式:
ROUGE-L = L C S ( generated , reference ) length of reference \text{ROUGE-L} = \frac{LCS(\text{generated}, \text{reference})}{\text{length of reference}} ROUGE-L=length of referenceLCS(generated,reference)
其中 LCS 是生成文本和参考文本之间的最长公共子序列。 -
ROUGE-S:基于 skip-gram(跳跃 n-gram)来计算重叠,允许 n-gram 中有跳跃的字符。
-
ROUGE-W:基于 加权词重叠,在 ROUGE-N 的基础上加权 n-gram 的贡献。
ROUGE 的计算例子
假设我们有以下 参考摘要(参考文本)和 生成摘要(模型生成的摘要):
参考摘要(Reference Text):
The cat sat on the mat.
生成摘要(Generated Text):
The cat sat on the rug.
1. 计算 ROUGE-1(Unigram 重叠)
ROUGE-1 计算的是 单个词(unigrams)的重叠。
- 参考摘要中的 unigram:
["The", "cat", "sat", "on", "the", "mat"]
- 生成摘要中的 unigram:
["The", "cat", "sat", "on", "the", "rug"]
计算过程:
- 重叠的 unigram 有:
["The", "cat", "sat", "on", "the"]
- 重叠的 unigram 数量是 5。
- 参考摘要中有 6 个 unigram,生成摘要中有 6 个 unigram。
ROUGE-1 = 重叠 unigram 数 生成摘要中的 unigram 数 = 5 6 ≈ 0.8333 \text{ROUGE-1} = \frac{\text{重叠 unigram 数}}{\text{生成摘要中的 unigram 数}} = \frac{5}{6} \approx 0.8333 ROUGE-1=生成摘要中的 unigram 数重叠 unigram 数=65≈0.8333
因此,ROUGE-1 的得分是 0.8333。
2. 计算 ROUGE-2(Bigram 重叠)
ROUGE-2 计算的是 双词组(bigrams)的重叠。
- 参考摘要中的 bigram:
[("The", "cat"), ("cat", "sat"), ("sat", "on"), ("on", "the"), ("the", "mat")]
- 生成摘要中的 bigram:
[("The", "cat"), ("cat", "sat"), ("sat", "on"), ("on", "the"), ("the", "rug")]
计算过程:
- 重叠的 bigram 有:
[("The", "cat"), ("cat", "sat"), ("sat", "on"), ("on", "the")]
- 重叠的 bigram 数量是 4。
- 参考摘要中有 5 个 bigram,生成摘要中有 5 个 bigram。
ROUGE-2 = 重叠 bigram 数 生成摘要中的 bigram 数 = 4 5 = 0.8 \text{ROUGE-2} = \frac{\text{重叠 bigram 数}}{\text{生成摘要中的 bigram 数}} = \frac{4}{5} = 0.8 ROUGE-2=生成摘要中的 bigram 数重叠 bigram 数=54=0.8
因此,ROUGE-2 的得分是 0.8。
3. 计算 ROUGE-L(最长公共子序列)
ROUGE-L 基于 最长公共子序列(LCS)计算,这能保留一些词序信息。我们需要计算生成文本和参考文本的最长公共子序列。
- 参考摘要:
["The", "cat", "sat", "on", "the", "mat"]
- 生成摘要:
["The", "cat", "sat", "on", "the", "rug"]
公共子序列为:["The", "cat", "sat", "on", "the"]
,长度为 5。
参考摘要长度为 6,生成摘要长度为 6。
ROUGE-L = LCS 长度 参考摘要长度 = 5 6 ≈ 0.8333 \text{ROUGE-L} = \frac{\text{LCS 长度}}{\text{参考摘要长度}} = \frac{5}{6} \approx 0.8333 ROUGE-L=参考摘要长度LCS 长度=65≈0.8333
因此,ROUGE-L 的得分是 0.8333。
结果总结:
ROUGE 指标 | 得分 |
---|---|
ROUGE-1 | 0.8333 |
ROUGE-2 | 0.8 |
ROUGE-L | 0.8333 |
七、总结
- ROUGE-1 衡量的是 unigram(单个词) 的重叠程度,广泛用于简单的文本比较。
- ROUGE-2 衡量的是 bigram(双词组) 的重叠程度,更关注词序信息。
- ROUGE-L 衡量的是 最长公共子序列(LCS),能捕捉到长距离的依赖关系。
ROUGE 系列指标广泛应用于 自动摘要、机器翻译、文本生成 等任务的性能评估,帮助我们量化生成文本与参考文本的相似度。