本地加载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)
相关推荐
AI360labs_atyun23 分钟前
腾讯推出电子牛马Marvis,好用吗?
人工智能·科技·ai
Dfreedom.24 分钟前
Windows、虚拟机、开发板组网通信原理及调试通联步骤
人工智能·windows·部署·边缘计算·开发板·模型加速
3DVisionary28 分钟前
蓝光三维扫描:医疗制造的精度焦虑怎么解
人工智能·算法·制造·蓝光三维扫描·医疗制造·三维检测·义齿检测
Are_You_Okkk_28 分钟前
基于MonkeyCode解析AI研发新模式,根治开发低效痛点
大数据·人工智能·开源·ai编程
好评笔记36 分钟前
机器学习面试八股——常用损失函数
人工智能·深度学习·算法·机器学习·校招
weixin_4684668538 分钟前
全局与局部注意力机制新手实战指南
人工智能·python·深度学习·算法·自然语言处理·transformer·注意力机制
weixin_468466851 小时前
工业相机成像原理新手入门指南
人工智能·自动化·机器视觉·工业相机·光学·光学系统·成像原理
回眸&啤酒鸭1 小时前
【回眸】CSDN新增功能测评——AI数字营销之内容创作
人工智能
小糖学代码1 小时前
LLM系列:环境搭建:5.Python-dotenv 环境变量管理
人工智能·python·深度学习·神经网络
云安全助手1 小时前
2026年企业级Claude中转服务深度评测:安全、稳定与速度的终极答案
人工智能·安全·claude·ai大模型