当前位置:   article > 正文

垂域LLM评测指标个人记录

垂域LLM评测指标个人记录

bertscore

1.安装

pip install bert-score

2.如果报错

  1. OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like roberta-large is not the path to a directory containing a file named config.json.
  2. Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.

解决办法:改为hf镜像网站

  1. pip install -U huggingface_hub
  2. export HF_ENDPOINT=https://hf-mirror.com

代码

  1. import os
  2. os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
  3. from huggingface_hub import hf_hub_download
  4. from bert_score import score
  5. # 定义参考句子和生成句子
  6. refs = ["The cat sat on the mat.", "It was raining outside."]
  7. cands = ["The cat sat on the mat.", "It was pouring outside."]
  8. # 使用bert_score计算分数
  9. P, R, F1 = score(cands, refs, lang='en', model_type="roberta-large", verbose=True)
  10. # 打印结果
  11. print("Precision:", P)
  12. print("Recall:", R)
  13. print("F1 score:", F1)

 

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/黑客灵魂/article/detail/965621
推荐阅读
相关标签
  

闽ICP备14008679号