本地加载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)
相关推荐
Sirius Wu2 分钟前
OpenClaw Skill:Matplotlib 可视化技能 + 沙箱双层隔离完整详解
服务器·网络·人工智能·安全·ai·架构·aigc
闻道且行之9 分钟前
TurboOCR:基于PP-OCRv6的极速Windows离线OCR工具,深度解析3.4GB依赖背后的技术架构
c++·人工智能·python·qt·机器学习·ocr
We0 AI11 分钟前
2026 年的 B2B 官网竞争,已经不只是页面竞争了
人工智能·aigc·#ai建站
橙臣程35 分钟前
深度学习2——CNN与RNN概述
rnn·深度学习·cnn
冬奇Lab41 分钟前
每日一个开源项目(第160篇):Destructive Command Guard - 在 AI Agent 运行 rm -rf 之前拦截它
人工智能·安全·开源
绝世番茄41 分钟前
鸿蒙HarmonyOS ArkTS原生拖拽排序深度解析
深度学习·华为·list·harmonyos·鸿蒙
IvorySQL1 小时前
PG 日报|SQL/PGQ 图查询基于联接重写机制实现
数据库·人工智能·sql·postgresql·区块链·ivorysql
博图光电1 小时前
博图汽车零配件视觉检测与测量解决方案
人工智能·汽车·视觉检测
仿生狮子1 小时前
别再说“全栈”了,AI 时代团队只认这 5 种人
前端·人工智能·后端