本地加载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)
相关推荐
Rsun045514 分钟前
AI智能体学习路线
人工智能·学习
soldierluo17 分钟前
基于window+wsl+Ubuntu的openclaw私有化部署
人工智能
LJ97951111 小时前
告别通稿地狱:Infoseek用工程思维重构媒介宣发
人工智能
互联网江湖1 小时前
快手营收利润双增,可灵AI会不会成为第二个Seedance?
大数据·人工智能
菜包eo1 小时前
Kingsway Ultra:从视频到 AI,出海企业完整解决方案
人工智能·外贸b2b·外贸独立站·openclaw·kingwayvideo·视频营销
pp起床1 小时前
Part03:设计提示的通用技巧
人工智能
pp起床1 小时前
Part02:基本概念以及基本要素
大数据·人工智能·算法
landuochong2002 小时前
OpenClaw 架构文档
人工智能·架构·openclaw
Tony Bai2 小时前
告别古法编程黄金时代:AI 时代不会再有新编程语言诞生的土壤
人工智能
cxr8282 小时前
OpenClaw与NetLogo之间的调用与数据交互机制
人工智能·交互·netlogo·openclaw