本地加载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)
相关推荐
Element_南笙4 分钟前
VGG网络-深度学习经典架构解析
网络·深度学习·架构
薛定猫AI7 分钟前
【深度解析】Claude Code Skills 工作流:用知识图谱、设计规范与 Agent 工具链提升 AI 编程效率
人工智能·知识图谱·设计规范
AI自动化工坊9 分钟前
Cloudflare Project Think技术实践:零成本AI Agent部署架构深度解析
人工智能·架构·agent·cloudflare
IT_陈寒39 分钟前
JavaScript里这个隐式类型转换的坑,我终于爬出来了
前端·人工智能·后端
星幻元宇VR43 分钟前
VR航空航天科普设备助力航天知识普及
人工智能·科技·学习·安全·vr·虚拟现实
Agent产品评测局1 小时前
制造业生产调度自动化落地,完整步骤与避坑指南:2026企业级智能体选型与实战全景
运维·人工智能·ai·chatgpt·自动化
志栋智能1 小时前
超自动化巡检:让合规与审计变得轻松简单
运维·网络·人工智能·自动化
用户1708542888852 小时前
用 Codex + Huashu Design Skill,15 分钟做出设计师级别的演示文稿(PPT)
人工智能
Elastic 中国社区官方博客2 小时前
Elasticsearch:智能搜索 - AI builder 及 skills
大数据·人工智能·elasticsearch·搜索引擎·ai·信息可视化·全文检索
陶陶然Yay2 小时前
神经网络卷积层梯度公式推导
人工智能·深度学习·神经网络