本地加载hugging face模型:Bert

找了个hf的镜像站,把config.json和pytorch_model.bin两个文件进行下载下来,模型文件uncased_L-12_H-768_A-12.zip下载下来先。

解压模型文件压缩包,把前面下载的两个文件也放进去,总共6个文件。这个文件夹就是代码

tokenizer = BertTokenizer.from_pretrained(BERT_PATH)

BERT_PATH这里对应的文件路径。

Some weights of BertForSequenceClassification were not initialized from the model checkpoint at bert-base-uncased and are newly initialized: 'classifier.bias', 'classifier.weight'

pip install tensorflow

复制代码
from transformers import BertModel, BertTokenizer

model_name = 'bert-base-uncased'
tokenizer = BertTokenizer.from_pretrained(model_name)
model = BertModel.from_pretrained(model_name, from_tf=True)
相关推荐
AI Coder 码农王24 分钟前
AgentScope Java v2 第3课,从 ReActAgent 到 HarnessAgent
人工智能
格物致胜工业数智技术26 分钟前
明治EOS系列传感器技术解析:精密制造高反光金属件在位检测
人工智能·制造
甲维斯32 分钟前
DeepSeek 新版还是难评!
人工智能
晨间晓1 小时前
图片细节丰富不丰富?用华为云码道开发 OpenCV 纹理复杂度分析工具
人工智能·opencv·华为云
硅谷秋水1 小时前
面向机器人的上下文学习:方法与应用
深度学习·机器学习·语言模型·机器人
2603_965148111 小时前
电商选品调研:通过关键词搜索API获取市场热销商品,结合商品详情API分析竞品卖点与定价
开发语言·数据库·人工智能·python·信息可视化
镜象科技1 小时前
什么是好的校园AI心理健康解决方案服务商?从中外校园心理服务的一天说起
人工智能
Geeys1 小时前
拼多多单品推广完整方案(可直接落地)
大数据·人工智能
泡椒鸡脚2 小时前
AI室内设计风格融合:把布局、材质和光影参考分开写
人工智能·材质
袁俪2 小时前
世界模型与智能体
人工智能