问题:

python使用transformers时报错:

Repo id must use alphanumeric chars or '-', '_', '.', '--' and '..' are forbidden, '-' and '.' cannot start or end the name, max length is 96

Repo ID必须使用字母数字字符或者'-'、'_'、'...',禁止使用'--'和'...','-'和'...'不能作为名称的开始或结束,最大长度为96。

解决方法:

Repo id must use alphanumeric chars or '-', '_', '.', '--' and '..' are forbidden, '-' and '.' cannot start or end the name, max length is 96

发现是因为在代码中不小心把文件名mDeBERTa-v3-base-mnli-xnli中的"-"写成了"_"将代码中的"_"全部改为"-"后该错误消失。

from transformers import pipeline

model_name = r"D:\NLP\model\mDeBERTa-v3-base-mnli-xnli"

classifier = pipeline("zero-shot-classification", model=model_name)

虽然该错误说的是Repo ID必须使用字母数字字符或者'-'、'_'、'...',禁止使用'--'和'...','-'和'...'不能作为名称的开始或结束,但也可能是因为模型文件夹的名字写错了

Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐