我正在尝试执行huggingface网站的示例代码:
from transformers import GPTJTokenizer, TFGPTJModel
import tensorflow as tf
tokenizer = GPTJTokenizer.from_pretrained("EleutherAI/gpt-j-6B")
model = TFGPTJModel.from_pretrained("EleutherAI/gpt-j-6B")
inputs = tokenizer("Hello, my dog is cute", return_tensors="tf")
outputs = model(inputs)
last_hidden_states = outputs.last_hidden_state
我使用的是anaconda,我事先安装了带有conda install -c huggingface transformers
的变压器包,如文档中所述。但当我试图执行代码时,我仍然会遇到这个错误。弹出以下错误消息:ModuleNotFoundError: No module named 'huggingface_hub.utils'
如何解决此错误?
我也遇到了同样的问题。在我的案例中,这与libssl库的工作在一个新版本的拥抱脸中被搞砸有关。降级一点解决了我的问题。
这将把标记化器降级到0.10.3,把transformer降级到适合标记化器的最后一个版本。
conda install -c huggingface transformers==4.14.1 tokenizers==0.10.3 -y
如果您随后收到错误Import Error : cannot import name 'create_repo' from 'huggingface_hub'
,您还应该使用更新您的huggingface_hub版本
conda install -c huggingface huggingface_hub
请尝试:
conda install -c conda-forge huggingface_hub