本地加载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·Earth)29 分钟前
GPT-5.1发布!你的AI更暖更智能!
人工智能·gpt·神经网络·aigc·agi
宁渡AI大模型38 分钟前
从生成内容角度介绍开源AI大模型
人工智能·ai·大模型·qwen
xier_ran1 小时前
深度学习:Mini-Batch 梯度下降(Mini-Batch Gradient Descent)
人工智能·深度学习·batch
Microvision维视智造1 小时前
变速箱阀芯上料易错漏?通用 2D 视觉方案高效破局,成汽车制造检测优选!
人工智能
AAA小肥杨1 小时前
探索K8s与AI的结合:PyTorch训练任务在k8s上调度实践
人工智能·pytorch·docker·ai·云原生·kubernetes
飞哥数智坊2 小时前
TRAE Friends 落地济南!首场线下活动圆满结束
人工智能·trae·solo
m0_527653902 小时前
NVIDIA Orin NX使用Jetpack安装CUDA、cuDNN、TensorRT、VPI时的error及解决方法
linux·人工智能·jetpack·nvidia orin nx
wbzuo2 小时前
Clip:Learning Transferable Visual Models From Natural Language Supervision
论文阅读·人工智能·transformer
带土12 小时前
2. YOLOv5 搭建一个完整的目标检测系统核心步骤
人工智能·yolo·目标检测
1***Q7842 小时前
PyTorch图像分割实战,U-Net模型训练与部署
人工智能·pytorch·python