Python NLTK中有BLEU评分的实现,
nltk.translate.bleu_score.corpus_bleu
但我不确定它是否与 mtevalv13a.pl script 相同.
它们有什么区别?
最佳答案
TL;DR
使用https://github.com/mjpost/sacrebleu在评估机器翻译系统时。
简而言之
不,NLTK 中的 BLEU 与 mteval-13a.perl
并不完全相同。
但它可以非常接近,请参阅 https://github.com/nltk/nltk/issues/1330#issuecomment-256237324
nltk.translate.corpus_bleu
corresponds tomteval-13a.pl
up to the 4th order of ngram with some floating point discrepancies
详细的比较和使用的数据集可以从https://github.com/nltk/nltk_data/blob/gh-pages/packages/models/wmt15_eval.zip下载或:
import nltk
nltk.download('wmt15_eval')
主要区别:
<小时/>长
mteval-13a.pl
和 nltk.translate.corpus_bleu
之间有几个区别:
第一个区别是
mteval-13a.pl
带有自己的 NIST 分词器,而 NLTK 版本的 BLEU 是该指标的实现并假设输入已预先标记化。- 顺便说一句,这个ongoing PR将弥合 NLTK 和 NIST 分词器之间的差距
另一个主要区别是
mteval-13a.pl
期望输入采用.sgm
格式,而 NLTK BLEU 则采用 python 列表字符串,请参阅README.txt in the zipball here for more information of how to convert textfile to SGM .mteval-13a.pl
期望 ngram 顺序至少为 1-4。如果句子/语料库的最小 ngram 阶数小于 4,它将返回 0 概率,即math.log(float('-inf'))
。为了模拟这种行为,NLTK 添加了一个_emulate_multibleu
标志:mteval-13a.pl
能够生成 NIST 分数,而 NLTK 没有 NIST 分数实现(至少目前还没有)- NLTK 中的 NIST 分数为 upcoming in this PR
除了差异之外,NLTK BLEU 分数还包含更多功能:
处理原始 BLEU(Papineni,2002 年)忽略的边缘情况
此外,为了处理 Ngram 最大阶数 < 4 的边缘情况,各个 ngram 精度的统一权重将重新加权,以使权重的质量总和为 1.0
同时 NIST has a smoothing method对于几何序列平滑,NLTK has an equivalent object with the same smoothing method以及更多平滑方法来处理 Chen and Collin, 2014 中的句子级 BLEU
最后,为了验证 NLTK 版本的 BLEU 中添加的功能,添加了回归测试来说明它们,请参阅 https://github.com/nltk/nltk/blob/develop/nltk/test/unit/translate/test_bleu.py
关于machine-learning - mteval-v13a.pl 和 NLTK BLEU 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46084574/