我克隆了这个存储库/文档https://huggingface.co/EleutherAI/gpt-neo-125M
无论是在google上运行还是在本地运行,我都会得到以下错误。我还用这个安装了变压器
pip install git+https://github.com/huggingface/transformers并确保配置文件名为config.json。
5 tokenizer = AutoTokenizer.from_pretrained("gpt-neo-125M/",from_tf=True)
----> 6 model = AutoModelForCausalLM.from_pretrained("gpt-neo-125M",from_tf=True)
7
8
3 frames
/usr/local/lib/python3.7/dist-packages/transformers/file_utils.py in __getattr__(self, name)
AttributeError: module transformers has no attribute TFGPTNeoForCausalLM完整代码:
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neo-125M",from_tf=True)
model = AutoModelForCausalLM.from_pretrained("EleutherAI/gpt-neo-125M",from_tf=True)变压器-cli env结果:
transformers版本: 4.10.0.dev0collab和本地都有TensorFlow 2.5.0版本
发布于 2021-08-04 19:14:11
我的解决方案是首先编辑源代码,删除在包前面添加"TF“的行,因为正确的变压器模块是GPTNeoForCausalLM,但是在源代码中的某个地方,它在前面手动添加了一个"TF”。
其次,在克隆存储库之前,必须运行
git lfs install. 这个链接帮助我正确地安装了git https://askubuntu.com/questions/799341/how-to-install-git-lfs-on-ubuntu-16-04。
发布于 2021-07-31 20:36:23
尝试不使用from_tf=True标志,如下所示:
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neo-125M")
model = AutoModelForCausalLM.from_pretrained("EleutherAI/gpt-neo-125M")from_tf期望pretrained_model_name_or_path (即第一个参数)是加载保存的Tensorflow检查点的路径。
https://stackoverflow.com/questions/68604289
复制相似问题