在Python中计算候选句和参考句之间的BLEU分数

问题描述 投票:0回答:1

我正在计算 2 个句子之间的 BLEU 分数,这两个句子看起来与我非常相似,但我得到的 BLEU 分数非常低。应该会发生吗?

prediction = "I am ABC."
reference = "I'm ABC."

from nltk.translate.bleu_score import sentence_bleu, corpus_bleu
from nltk.translate.bleu_score import SmoothingFunction
# Tokenize the sentences
prediction_tokens = prediction.split()
reference_tokens = reference.split()
   
# Calculate BLEU score
bleu_score = sentence_bleu([reference_tokens], prediction_tokens, smoothing_function=SmoothingFunction().method4)

# Print the BLEU score
print(f"BLEU score: {bleu_score:.4f}")

Output is 0.0725
python machine-learning artificial-intelligence statistical-test
1个回答
0
投票

是的,有两个原因:

  1. 标记化:“我是”与“我是”会导致不同的标记化。 BLEU 分数对代币非常敏感。不同的代币化应该会产生重大影响。
  2. 短句子:对于非常短文本,BLEU 是出了名的不可靠。如果一开始没有太多文字,分数将受到微小差异的不成比例的影响。

希望您找到您正在寻找的答案🤓。

© www.soinside.com 2019 - 2024. All rights reserved.