使用 ROUGE 进行评估
ROUGE 常用于评估摘要任务,因为它会比较预测与参考之间的相似度。已为您提供了一个模型生成的摘要 predictions,以及一个用于验证的参考摘要 references。请计算得分,看看模型的表现如何。
evaluate 库已为您加载。
本练习是课程的一部分
Python 中的 LLM 入门
练习说明
- 加载 ROUGE 指标。
- 计算预测摘要与参考摘要之间的 ROUGE 分数。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Load the rouge metric
rouge = ____
predictions = ["""Pluto is a dwarf planet in our solar system, located in the Kuiper Belt beyond Neptune, and was formerly considered the ninth planet until its reclassification in 2006."""]
references = ["""Pluto is a dwarf planet in the solar system, located in the Kuiper Belt beyond Neptune, and was previously deemed as a planet until it was reclassified in 2006."""]
# Calculate the rouge scores between the predicted and reference summaries
results = ____
print("ROUGE results: ", results)