环境:
1.操作系统:Windows11
2.Python版本:Python 3.9.10
一、下载安装
pip install bert-score
二、示例代码
此示例代码由chatGPT自动生成,参考句子与生成句子皆以数组的形式输入。
from bert_score import score
# 定义参考句子和生成句子
refs = ["The cat sat on the mat.", "It was raining outside."]
cands = ["The cat sat on the mat.", "It was pouring outside."]
# 使用bert_score计算分数
P, R, F1 = score(cands, refs, lang='en', model_type=