当前位置:   article > 正文

from_pretrained(‘bert-base-uncased‘) 报错_model name 'bert-base-uncased' was not found in mo

model name 'bert-base-uncased' was not found in model name list (bert-base-u

OSError: Model name ‘bert-base-cased’ was not found in tokenizers model name list (bert-base-uncased, bert-large-uncased, bert-base-cased, bert-large-cased, bert-base-multilingual-uncased, bert-base-multilingual-cased, bert-base-chinese, bert-base-german-cased, bert-large-uncased-whole-word-masking, bert-large-cased-whole-word-masking, bert-large-uncased-whole-word-masking-finetuned-squad, bert-large-cased-whole-word-masking-finetuned-squad, bert-base-cased-finetuned-mrpc, bert-base-german-dbmdz-cased, bert-base-german-dbmdz-uncased, TurkuNLP/bert-base-finnish-cased-v1, TurkuNLP/bert-base-finnish-uncased-v1, wietsedv/bert-base-dutch-cased). We assumed ‘bert-base-cased’ was a path, a model identifier, or url to a directory containing vocabulary files named [‘vocab.txt’] but couldn’t find such vocabulary files at this path or url.

在huggingface上把bert模型下载下来,放到一个文件夹里,就叫bert-base-uncased,'bert-base-uncased’改为"./bert-base-uncased",解决

from transformers import BertTokenizer, BertModel
tokenizer = BertTokenizer.from_pretrained(‘./bert-base-uncased’)
model = BertModel.from_pretrained(“./bert-base-uncased”)
text = “Replace me by any text you’d like.”
encoded_input = tokenizer(text, return_tensors=‘pt’)
output = model(**encoded_input)
print(output)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/347529
推荐阅读
相关标签
  

闽ICP备14008679号