本地加载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)
相关推荐
youcans_16 分钟前
【HALCON机器视觉实战】专栏介绍
图像处理·人工智能·计算机视觉·halcon
火山引擎开发者社区19 分钟前
火山引擎 veRoCE 获权威认证:IANA 官方为 veRoCE 分配专属 UDP 端口号 4794
人工智能
飘落的数码折腾日记25 分钟前
你的AI Agent可能正在“叛变“ | 5类真实威胁与四层防御
人工智能
放羊郎34 分钟前
基于ORB-SLAM2算法的优化工作
人工智能·算法·计算机视觉
AI袋鼠帝1 小时前
字节的技术决心,都藏在这个动作里
人工智能
AI袋鼠帝1 小时前
企微又偷偷进化AI,并开始不对劲了..
人工智能
工业机器人销售服务1 小时前
2026 年,探索专业伯朗特机器人的奇妙世界
人工智能·机器人
摆烂大大王1 小时前
AI 日报|2026年5月9日:四部门力推AI与能源双向赋能,AI终端国标出台,中国大模型融资潮涌
人工智能
萑澈2 小时前
编程能力强和多模态模型的模型后训练
人工智能·深度学习·机器学习
LaughingZhu2 小时前
Product Hunt 每日热榜 | 2026-05-08
人工智能·经验分享·深度学习·神经网络·产品运营