本地加载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)
相关推荐
打工仔折腾 AI14 小时前
Pascal Editor 本地部署实战:Bun 启动 WebGPU 3D 编辑器并解决公网访问报错
人工智能·后端·python·性能优化
甲维斯14 小时前
《钢铁洪流》开发笔记:AI策略升级!
人工智能·游戏开发
技术程序猿华锋14 小时前
深度解析 GPT-Image-2.5:双架构模型演进、获取API 接入与工程化开发教程
人工智能·gpt
镜象科技14 小时前
AI心检选购清单:10个问题的决策树
人工智能
ai大模型-探索者14 小时前
BERT模型压缩-量化实战
bert
Omics Pro14 小时前
AI药物研发10原则!欧盟EMA×美国FDA
数据库·人工智能·算法·机器学习·自然语言处理
冬奇Lab14 小时前
DeepSeek Harness 系列(10):写一个完整的 dsh 插件——从需求到上线
人工智能·学习·开源
Python图像识别14 小时前
10-【2027毕设】YOLO11PCB缺陷检测识别系统 - Python完整源码+PyQt5界面+训练模型+数据集
python·深度学习·yolo·毕业设计·毕设
云杂项14 小时前
Safety at Scale: A Comprehensive Survey of Large Model and Agent Safety(LLMs章节)
人工智能·安全
cxk180827214 小时前
2026 GEO 优化实战指南:精采信时代昆明 AI 营销服务商选型方法论
大数据·人工智能·机器学习·geo·昆明geo