本地加载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)
相关推荐
qyz_hr5 小时前
拥抱AI,红海云筑牢企业组织与人力数据底层能力
人工智能
Capricorn19885 小时前
个人知识库接入大模型频现“幻觉引用”?排查 RAG 溯源失效问题,解析知芽构建可信第三大脑的底层架构
大数据·论文阅读·人工智能·笔记·架构·论文笔记
LaughingZhu5 小时前
Product Hunt 每日热榜 | 2026-08-27
人工智能·深度学习·神经网络·搜索引擎·百度
时代分流5 小时前
生成式搜索时代的 GEO 技术体系与落地实践:解析矩擎 GEO 5.0 全栈架构
人工智能
DeepAgent5 小时前
AI Agent 工程实践(35):我的 AI Engineering OS 最终架构
大数据·人工智能·agent
陈年老古董6 小时前
深度学习入门笔记:从神经元到深度神经网络
人工智能·笔记·深度学习·神经网络·学习
ZGIAI6 小时前
ZGI Workflow:外部接口成功后,任务状态怎么落下来
人工智能·架构
ZGIAI6 小时前
ZGI Agent 发布:配置改了,线上为何还是旧版本
人工智能·架构
richard_first6 小时前
英伟达“循环融资”AI实验室:模式解析与行业影响
人工智能
2601_955662466 小时前
短视频配音 7 款测评:旁白情绪、断句、呼吸感完整打分
人工智能·音视频·语音识别