本地加载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)
相关推荐
小O的算法实验室6 小时前
IEEE TCDS,基于改进双神经网络三维未知环境多机器人协同区域覆盖搜索
人工智能·神经网络·机器人
无凭6 小时前
DeepSeek Harness 为什么需要 Cordis:从 Everything is Plugin 开始看
人工智能·架构
炮哥聊AI6 小时前
会调工具的 Agent 只值一半:真正的业务智能体,得会"记仇"
人工智能·agent
字节跳动数据库6 小时前
火山 PostgreSQL Serverless × 飞书妙搭:把 AI 装进数据库,一句话唤醒数据智能
数据库·人工智能·后端
智购科技自动贩卖机6 小时前
自动售货机硬件主控方案选型实战:单片机、树莓派、ESP32怎么选?
人工智能·单片机·嵌入式硬件·物联网·网络协议·yolo·架构
用户1917291270836 小时前
企业 Agent 运行时护栏:独立安全层四道防线设计与落地
人工智能
beiju6 小时前
从 Meta AI Mac 版看 Agent 产品:桌面端真正解决的是交付上下文
人工智能
Scene2166 小时前
旧 REST 接口封装成 MCP 服务:完整实战指南
人工智能·后端
2301_786756606 小时前
不做分子仿真、不布局自动化实验室,垂直科研智能平台同样跑通 AI for Science 可持续变现
运维·人工智能·自动化
大数据点灯人6 小时前
【大模型】深度解答:OOV 与 Tokenizer 词汇表共用问题
人工智能·深度学习·ai·大模型·transformer