本地加载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)
相关推荐
CoderJia程序员甲7 分钟前
GitHub 热榜项目 - 日榜(2026-1-7)
人工智能·ai·大模型·github·ai教程
s09071368 分钟前
【综述】前视二维多波束成像声呐(FLS)图像处理算法全解析:从成像到深度学习
图像处理·人工智能·算法·声呐·前视多波束
shdwak....sad8 分钟前
DeepAudit AI多智能体代码审计项目学习与解读(四)
人工智能·安全
声网12 分钟前
旧金山活动丨聊聊 AI 客服和 AI Call Agent,Conversational AI Meetup@SF,1 月 12 日
人工智能
幂律智能13 分钟前
2025年终回顾 | AI向实,共赴山海
人工智能·经验分享
星河耀银海16 分钟前
人工智能从入门到精通:机器学习基础算法实战与应用
人工智能·算法·机器学习
落叶,听雪19 分钟前
河南AI建站
人工智能·python
工藤学编程21 分钟前
零基础学AI大模型之Zero-Shot和Few-Shot
人工智能
scott19851221 分钟前
DIFIX3D+: Improving 3D Reconstructions with Single-Step Diffusion Models
人工智能·计算机视觉·扩散模型·生成式
竹君子21 分钟前
新能源知识库(167)什么是章鱼能源?
大数据·人工智能·能源