【发布时间】:2021-04-03 20:45:56
【问题描述】:
我很好奇是否有人熟悉使用 NLTK's BLEU score calculation 和 SacreBLEU 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