本地加载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)
相关推荐
qyr678919 分钟前
全球汽车和航空航天用磁铁材料市场竞争格局变化趋势
大数据·人工智能·物联网·自动化·汽车和航空航天用磁铁材料
ZONGYUAN-ROOT1 小时前
【开源发布】约束运行时(Constraint Runtime)开源发布:给智能体规模化部署加四层护栏
人工智能·开源
小马过河R2 小时前
真实场景:用户自建定时任务与推送提醒Agent-架构设计与可靠性实践
数据库·人工智能·agent·vibe coding·ai coding
山川而川-R2 小时前
RK3588边缘计算:YOLOv8 使用Android NDK部署_笔记1
人工智能·笔记·yolo·安卓
FengY_HYY2 小时前
Agent 时代,你的身份由你来定义
人工智能·agent·游戏开发
shengjk13 小时前
AI最大的讽刺:你以为它能结束996,资本却可能用它开启997
人工智能
fanstuck3 小时前
AI 回答得头头是道,怎么一查原文,条号就对不上了?
人工智能·aigc·agent
硅谷秋水3 小时前
BAAI的PhysCapBench分析
人工智能·机器学习·机器人