本地加载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)
相关推荐
Elastic 中国社区官方博客14 分钟前
你的 AI agent 不需要你的 API 密钥:使用 OAuth 2.1 对 Elasticsearch MCP 服务器进行身份验证
大数据·运维·人工智能·elasticsearch·搜索引擎·全文检索
airobotcn21 分钟前
AI Agent下工厂:大模型如何驱动巡检机器人自主决策
人工智能·机器人·自动化·无人机
能源革命25 分钟前
AI+能源前沿2026-08-15
人工智能·能源
Dawson Zhu35 分钟前
为什么智能体 Agent 需要本体 Ontology
人工智能·语言模型·架构·制造·agi
qfljg40 分钟前
如何学习opencode和openclaw源码
深度学习
恣逍信点1 小时前
《凌微经》静态自悖——变化之自因
人工智能·科技·算法·机器学习·业界资讯·拓扑学·哲学
在世修行1 小时前
深度图像数据格式与RAW文件解析:从字节到三维世界的桥梁
人工智能·数码相机·计算机视觉
chen_zn951 小时前
《VLA 系列》RLT | RL Token | 轻量 Actor-Critic | 在线强化学习与源码解析
人工智能·强化学习·具身智能·vla
fthux1 小时前
装闭 RenoPit 源码解析(10):AI如何审查装修合同与报价单
人工智能·ai·开源·github·open source·renopit
AI_AGENT_DEV_AI1 小时前
AI 智能体的开发费用
人工智能