Module ‘accuracy’ doesn’t exist on the Hugging Face Hub either.

问题:

1
2
Module 'accuracy' doesn't exist on the Hugging Face Hub either.
Module 'f1' doesn't exist on the Hugging Face Hub either.

原因

出现这个错误,主要在使用evaluate时,加载accuarcy,由于网络问题访问不到导致的。

1
acc_metric = evaluate.load("accuracy")

解决方案

  1. 下载对应的py文件,然后从本地加载
1
https://github.com/huggingface/datasets/tree/main/metrics
  1. 从本地加载评估模块
1
2
3
from datasets import load_metric
acc_metric = load_metric("./accuracy.py")
f1_metirc = load_metric("./f1.py")