本地加载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)
相关推荐
minhuan28 分钟前
大模型应用:AI智能体高并发实战:Redis缓存+负载均衡协同解决推理超时难题.133
人工智能·redis·智能体推理缓存·智能体负载均衡·大模型集群应用
圣殿骑士-Khtangc1 小时前
Windsurf AI IDE 超详细使用教程:从安装到实战,一站式上手
人工智能·ai编程·编程助手·windsurf
weixin_505154466 小时前
打破传统界限:Bowell Studio引领3D作业指导新纪元
人工智能·3d·制造·数据安全·数字孪生·数据可视化
ModelHub XC信创模盒8 小时前
中国信创AI生态下 “信创模盒”社区战略招募种子用户
人工智能·大模型·开发者·信创·算力
袋鼠云数栈9 小时前
集团数字化统战实战:统一数据门户与全业态监管体系构建
大数据·数据结构·人工智能·多模态
廋到被风吹走9 小时前
【AI】Codex 多语言实测:Python/Java/JS/SQL 效果横评
java·人工智能·python
cskywit9 小时前
【IEEE TNNLS 2025】赋予大模型“跨院行医”的能力:基于全局与局部提示的医学图像泛化框架 (GLP) 解析
人工智能
2501_948114249 小时前
AI API Gateway 选型指南:2026 年生产环境下的聚合平台深度对比
人工智能·gateway
实在智能RPA9 小时前
Agent 在物流行业能实现哪些自动化?——深度拆解 AI Agent 驱动的智慧物流新范式
运维·人工智能·ai·自动化
TechubNews9 小时前
Jack Dorsey:告别传统公司层级,借助 AI 走向智能体架构
大数据·人工智能