本地加载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)
相关推荐
海边夕阳20063 小时前
智能体 AI 架构的务实转向:从架构狂欢到治理优先
人工智能·自然语言处理·架构
会飞锦鲤3 小时前
基于Mask R-CNN 手机屏幕缺陷检测
pytorch·深度学习·计算机视觉·缺陷检测·实例分割·工业视觉·mask r-cnn
Csvn3 小时前
WorkBuddy 使用指南:连上不等于有权限-外部数据接入与排障
人工智能
回眸&啤酒鸭5 小时前
【回眸】AI 大模型驱动 Tessy 单元测试集成效果全景展示
网络·人工智能·单元测试
AI视频工具指南5 小时前
怎么用AI写短剧里的误会?猫斯卡、小云雀、LibTV对比
人工智能·aigc
邂逅and回眸6 小时前
具身评测:怎么衡量一个机器人模型的好坏
人工智能·机器人
世冠科技6 小时前
世冠科技董事长李京燕受邀出席第三十八届中国仿真大会并作主旨报告
人工智能·科技
aifannihao6 小时前
AI 学习第 29 课:loss 不动先查梯度,177 的范数不是爆炸是累积
pytorch·深度学习·梯度·学习路线·训练监控
7177776 小时前
国内 AI 研发项目管理工具选型:Gitee 在代码托管与全流程管理中的定位
人工智能·gitee