本地加载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)
相关推荐
bryant_meng3 分钟前
【Reading Notes】(10.4)Favorite Articles from 2026 April
人工智能·大模型·行业资讯·vibe coding
ZFSS5 分钟前
VS Code + Hailuo MCP 使用指南
人工智能·ai·copilot·ai编程·ai写作
蜀道山老天师5 分钟前
OpenClaw Skills 技能开发 + 企业运维全场景实战(进阶篇)
人工智能·windows·microsoft
AndrewHZ6 分钟前
【LLM技术全景】开源大模型生态:如何选择适合你的基座模型?
人工智能·深度学习·语言模型·开源·llm·transformer·基座模型
三更两点6 分钟前
AI拉呱-2026年06月04日AI技术洞察简报
人工智能
AI导出鸭PC端7 分钟前
ChatGPT怎么生成word文档?「AI 导出鸭」解决格式丢失痛点
人工智能·ai·chatgpt·word·豆包·ai导出鸭
装不满的克莱因瓶9 分钟前
自动微分的原理:计算图与前向传播
人工智能·pytorch·python·数学·ai·微积分·计算图
杭州华望MBSE11 分钟前
AI应用园地(1)| AI驱动需求工程升级—条目化、模型化、追溯化的三位一体实践
大数据·人工智能·mbse·sysml·ai助手
运维小欣13 分钟前
AI可观测厂商选型指南(2026版)
人工智能
2301_8185277817 分钟前
瑜伽服供应链优化——AI让每一件都准时高品质交付
人工智能