【问题标题】:What's the difference between NLTK's BLEU score and SacreBLEU?NLTK 的 BLEU 分数和 SacreBLEU 有什么区别?
【发布时间】:2021-04-03 20:45:56
【问题描述】:

我很好奇是否有人熟悉使用 NLTK's BLEU score calculationSacreBLEU library 之间的区别。

特别是,我使用了这两个库的句子 BLEU 分数,是整个数据集的平均值。两者给出不同的结果:

>>> from nltk.translate import bleu_score
>>> from sacrebleu import sentence_bleu
>>> print(len(predictions))
256
>>> print(len(targets))
256
>>> prediction = "this is the first: the world's the world's the world's the \
... world's the world's the world's the world's the world's the world's the world \
... of the world of the world'"
...
>>> target = "al gore: so the alliance for climate change has launched two campaigns."
>>> print(bleu_score.sentence_bleu([target], prediction))
0.05422283394039736
>>> print(sentence_bleu(prediction, [target]).score)
0.0
>>> print(sacrebleu.corpus_bleu(predictions, [targets]).score)
0.678758518214081
>>> print(bleu_score.corpus_bleu([targets], [predictions]))
0

如您所见,存在许多令人困惑的不一致之处。我的 BLEU 分数不可能是 67.8%,但也不应该是 0%(有很多重叠的 n-gram,比如“the”)。

如果有人能对此有所了解,我将不胜感激。谢谢。

【问题讨论】:

    标签: nltk machine-translation bleu


    【解决方案1】:

    NLTK 和 SacreBLEU 使用不同的标记化规则,主要用于处理标点符号的方式。 NLTK 使用自己的标记化,而 SacreBLEU 复制了 2002 年的原始 Perl 实现。标记化规则在 NLTK 中可能更精细,但它们使数量与原始实现无法比拟。

    您从 SacreBLEU 获得的语料库 BLEU 不是 67.8%,而是 0.67% - 与 NLTK 不同,来自 SacreBLEU 的数字已经乘以 100。所以,我不会说分数之间存在巨大差异。

    句子级别的 BLEU 可以使用不同的smoothing techniques,即使 3-gram 的 4-gram 精度为零,也应确保分数得到合理的值。但是,请注意,BLEU 作为句子级别的度量是非常不可靠的。

    【讨论】:

    • 如果句子级 BLEU 不可靠,我是否可以 1)在所有句子对中平均句子级 BLEU 或 2)获取所有预测和 ground-truth 对并计算语料库级 BLUE?跨度>
    • 如果您需要评估一个系统而不是单个句子,那么您应该使用语料库 BLEU。
    猜你喜欢
    • 2018-02-15
    • 2021-06-23
    • 2017-03-25
    • 2021-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-13
    相关资源
    最近更新 更多