本地加载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)
相关推荐
code_pgf6 分钟前
Transformer 原理讲解及可视化算子操作
人工智能·深度学习·transformer
碑 一7 分钟前
视频分割VisTR算法
人工智能·深度学习·计算机视觉
AI25122413 分钟前
免费AI视频生成工具技术解析与功能对比
人工智能·音视频
昨夜见军贴061615 分钟前
IA-Lab AI 检测报告生成助手:贯通电磁兼容与充电桩检测,打造新能源汽车报告全链路合规新体系
人工智能·汽车
新缸中之脑18 分钟前
PufferLib高性能强化学习库
人工智能
FS_Marking19 分钟前
短距离网络10G SFP+光模块选型指南
网络·人工智能
行走的小派20 分钟前
本地跑模型+原生开源鸿蒙:拆解香橙派AI手机的12TOPS端侧硬核玩法
人工智能·开源·harmonyos
2501_9481142420 分钟前
从 Claude Code 源码泄露看 2026 年 Agent 架构演进与工程化实践
大数据·人工智能·架构
小悟空20 分钟前
[AI生成]Iceberg 更新操作技术调研报告
人工智能