本地加载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)
相关推荐
阿里云大数据AI技术8 小时前
从“重复造轮”到“自主交付”---万物云 DataWorks Data Agent 落地实践实录
人工智能·agent
掘金安东尼8 小时前
智能体时代的预填充,为什么适合用流水线并行(Inferact 全文转译)
人工智能·agent
阿enna8 小时前
检测指标入门:IoU、Precision、Recall与mAP
人工智能·深度学习·算法·yolo·目标检测·计算机视觉·cnn
掘金安东尼8 小时前
Google Antigravity 和 Gemini Neon:哪些行为会封号,怎么降低风险(Flavio Copes 全文转译)
人工智能·google·gemini
kaixin_啊啊8 小时前
【零基础学AI】第 35 章——添加网页界面并部署
人工智能
程序员cxuan8 小时前
绝了,WorkBuddy 可以打通微信了
人工智能·后端·程序员
程序员cxuan9 小时前
再见了反重力,Google 又来搞事了
人工智能·后端·程序员
阿里云大数据AI技术9 小时前
阿里云灵骏真武超节点 Day0 适配星辰大模型 Xing4.1-Preview
人工智能
阿里云大数据AI技术9 小时前
EMR Serverless Ray 正式发布一站式具身智能数据处理平台
人工智能
Thomas.Sir10 小时前
第024讲:AI模型开发|多源接入:业务库、日志、埋点、三方 API 与 Kafka:批流两套入口,怎么共用一份 schema
人工智能·ai