本文主要是介绍离线使用evaluate,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、目录
- 步骤
- demo
- rouge-n 含义
二、实现
- 步骤
离线使用evaluate: 1. 下载evaluate 文件:https://github.com/huggingface/evaluate/tree/main2. 离线使用 路径+/evaluate-main/metrics/rouge
- demo
import evaluate
'''
离线使用evaluate: 1. 下载evaluate 文件:https://github.com/huggingface/evaluate/tree/main2. 离线使用 路径+/evaluate-main/metrics/rouge
'''
rouge=evaluate.load("/app/tensorrt_llm/examples/qwen2/evaluate-main/metrics/rouge")
predictions = ["Transformers Transformers are fast plus efficient","Good Morning", "I am waiting for new Transformers"]
references = [["HuggingFace Transformers are fast efficient plus awesome","Transformers are awesome because they are fast to execute"],["Good Morning Transformers", "Morning Transformers"],["People are eagerly waiting for new Transformer models","People are very excited about new Transformers"]
results = rouge.compute(predictions=predictions, references=references)
print(results)
- rouge-n 含义
ROUGE-N: 在 N-gram 上计算召回率
ROUGE-L: 考虑了机器译文和参考译文之间的最长公共子序列
ROUGE-W: 改进了ROUGE-L,用加权的方法计算最长公共子序列
这篇关于离线使用evaluate的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!