由于标题是自我描述的,我无法通过以下代码从transformers
包导入BertTokenizer
和TFBertModel
类:
from transformers import BertTokenizer, TFBertModel
tokenizer = BertTokenizer.from_pretrained(BERT_PATH)
model = TFBertModel.from_pretrained(BERT_PATH)
text = "Replace me by any text you'd like."
encoded_input = tokenizer(text, return_tensors='tf')
resp = model(encoded_input)
print(resp)
因此,我得到以下错误:
RuntimeError: Failed to import transformers.models.bert.modeling_tf_bert because of the following error (look up to see its traceback):
dlopen(/Users/tk/miniforge3/envs/QA-benchmark/lib/python3.10/site-packages/tensorflow-plugins/libmetal_plugin.dylib, 0x0006): symbol not found in flat namespace '_TF_GetInputPropertiesList'
下面是我的软件栈:
OS: macOS Ventura 13.3.1
Python: 3.10
TensorFlow: macOS-tensorflow 2.9.0
Transformers: 4.28.0
BERT model: uncased_L-12_H-768_A-12
p.s.我已经在GitHub的transformers仓库上发布了这个问题。
1条答案
按热度按时间x33g5p2x1#
试试这个!它对我很有效。