开始使用免费开始使用

使用 EM 进行评估

Exact Match 用于评估抽取式问答任务中模型的表现,顾名思义,它关注是否"完全匹配"。我们已为您提供用于评估的 predictionsreferencesevaluate 库已为您导入。

本练习是课程的一部分

Python 中的 LLM 入门

查看课程

练习说明

  • 加载 Exact Match 指标。
  • 计算 Exact Match 分数并打印结果。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Load the metric
exact_match = ___

predictions = ["It's a wonderful day", "I love dogs", "DataCamp has great AI courses", "Sunshine and flowers"]
references = ["What a wonderful day", "I love cats", "DataCamp has great AI courses", "Sunsets and flowers"]

# Compute the exact match and print the results
results = ____
print("EM results: ", ____)
编辑并运行代码