使用 nltk 的 meteor_score 模块评估模型时如何实现流星评分?

How can I implement meteor score when evaluating a model when using the meteor_score module from nltk?

我目前有 2 个文件,reference.txt 和 model.txt。这两个文本文件包含原始字幕和训练后生成的字幕。
我可以简单地执行以下操作以获得流星分数吗:

score = nltk.translate.meteor_score.meteor_score(reference, model)
print(np.mean(meteor_score))

我也看过 https://github.com/tylin/coco-caption 但我不知道如何实现它。

让我们从定义术语开始

参考:实际 text/ground 真相。如果有多个人为同一个数据点生成基本事实,您将有多个参考,并且所有参考都被认为是正确的

假设:candidate/predicted.

假设有 2 个人在看一张图片,他们说了标题

  • 这是一个苹果
  • 那是一个苹果

现在您的模型查看图像并进行预测

  • 这棵树上有一个苹果

您可以计算 meteor_score 预测使用的好坏程度

print (nltk.translate.meteor_score.meteor_score(
    ["this is an apple", "that is an apple"], "an apple on this tree"))
print (nltk.translate.meteor_score.meteor_score(
    ["this is an apple", "that is an apple"], "a red color fruit"))

输出:

0.6233062330623306
0.0

在您的情况下,您必须将 reference.txt 读入一个列表,并类似地将预测建模到另一个列表中。现在你必须为第一个列表中的每一行和第二个列表中的每一行获取 meteor_score,最后取一个平均值。