本地加载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)
相关推荐
FL16238631293 分钟前
电力设备红外图像与可见光图像配准数据集227对共454张无标注
深度学习
翔云12345611 分钟前
端侧推理:全面解析与深度洞察
人工智能·ai·大模型
AI精钢12 分钟前
AI Agent 从上线到删库跑路始末
网络·人工智能·云原生·aigc
码农小旋风17 分钟前
2026 终端 AI 编程工具深度横评:Claude Code、Codex CLI、Gemini CLI、Aider 怎么选
人工智能·gpt·claude
Chef_Chen1 小时前
论文解读:多模态智能体长期记忆突破:M3-Agent让AI像人一样“看、听、记、想“
人工智能·机器学习·agent·memory
zhuiyisuifeng1 小时前
2026AI办公革命:Gemini3.1Pro重塑职场效率
人工智能
threelab1 小时前
Three.js UV 图像变换效果 | 三维可视化 / AI 提示词
javascript·人工智能·uv
海兰1 小时前
【第28篇】可观测性实战:LangFuse 方案详解
人工智能·spring boot·alibaba·spring ai
feng14561 小时前
OpenSREClaw - 故障复盘和变更评审双 Agent 案例
运维·人工智能
普马萨特1 小时前
室内外定位导航的最新趋势(基于国际大会观察)
人工智能