问题一:安装transformers 的版本为4.3

报错:Invalid version: '0.10.1,<0.11'

解决方法:

pip install packaging==21.3

问题二:使用BertTokenizer出现ValueError: Connection error, and we cannot find the requested files in the cached path. Please try again or make sure your Internet connection is on.

具体代码:

from transformers import BertTokenizer

tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')

解决方案:

升级了transformers的版本为4.46 。解决了模型下载问题。又出现了问题三。

问题三:AttributeError: 'BertTokenizer' object has no attribute 'max_model_input_size'

解决方案:

pip install transformers==4.25.1

问题四:AttributeError: module ‘torch‘ has no attribute ‘frombuffer‘

frombuffer属性是在torch 版本为2.0之后拥有的,不改变torch版本的基础下:

解决方案:

pip install transformers==4.25.1
pip install safetensors==0.3.0

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐