bert-base-uncased使用
1.下载模型
https://github.com/google-research/bert?tab=readme-ov-file
2.下载config.json和pytorch_model.bin
https://huggingface.co/google-bert/bert-base-uncased/tree/main
3.解压缩到同一文件夹
4.代码测试
from transformers import BertModel,BertTokenizer
BERT_PATH = 'D:/bert/241109'
tokenizer = BertTokenizer.from_pretrained(BERT_PATH)
print(tokenizer.tokenize('I have an apple, thank you.'))
bert = BertModel.from_pretrained(BERT_PATH)
print('load bert model over')