使用 ROUGE 评估生成文本
给您提供了来自问答数据集(Softage-AI/sft-conversational_dataset)的 10 个样本。
您已经使用 TinyLlama-1.1B 为这些样本生成了答案,您的任务是将生成结果与标准答案进行质量评估。
该模型生成的答案保存在 test_answers 中,标准答案保存在 reference_answers 中。请使用 ROUGE 评估指标来评估模型生成质量。
本练习是课程的一部分
使用 Llama 3 进行微调
练习说明
- 导入评估类和指标(ROUGE 指标)。
- 实例化评估类并加载 ROUGE 指标。
- 使用给定的
reference_answers和test_answers运行评估器实例,计算 ROUGE 分数。 - 将结果中用于检查参考答案与生成答案之间词对重叠的分数,存入
final_score。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Import the evaluation library from Hugging Face
import ____
# Instantiate your evaluate library and load the ROUGE metric
rouge_evaluator = ____.load(____)
# Fill in the method, and place your reference answers and test answers
results = rouge_evaluator.____
# Extract the ROUGE1 score from the results dictionary
final_score = results[____]
print(final_score)