本地加载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)
相关推荐
智驭未来掌门人1 分钟前
从LLM Gateway到Agent Gateway:大模型网关架构演进的技术分析
人工智能
RisunJan2 分钟前
DeepSeek 全景技术指南:从混合推理架构到提示语工程实战(2026.09)
大数据·人工智能·架构
空堂与归3 分钟前
dsh 插件报「未注册 hmr」又空白?两处根因排查与解决
人工智能
能源革命4 分钟前
AI 日报 2026-09-10
人工智能·dubbo
武子康5 分钟前
SGLang 回答慢,时间究竟花在了哪里?
人工智能·llm·agent
派大_星8 分钟前
PyTorch CNN图片分类与数据增强实践
人工智能·深度学习·机器学习
jay神13 分钟前
【计算机毕业设计项目】基于 YOLO + ArcFace 的人脸识别检测系统
人工智能·深度学习·计算机视觉·毕业设计·课程设计·计算机毕业设计
长谷深风11117 分钟前
Checkpoint设计的三大生死关
大数据·人工智能·ai·大模型·ai智能体·tool·aiagent
DevNo20 分钟前
我的旅拍素材整理和剪辑记录
人工智能
程序员cxuan21 分钟前
DeepSeek V4.1 Flash 正式发布!
人工智能·后端·程序员