本地加载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)
相关推荐
KAI智习6 小时前
大模型榜单周报(2025/12/20)
人工智能·大模型
2501_907136827 小时前
AI 小说生成器-基于 Tauri 2.0 + Vue 3 + TypeScript 的智能小说创作工具
人工智能·软件需求
love530love7 小时前
ComfyUI 升级 v0.4.0 踩坑记录:解决 TypeError: QM_Queue.task_done() 报错
人工智能·windows·python·comfyui
金士镧(厦门)新材料有限公司7 小时前
稀土化合物:推动科技发展的“隐形力量”
人工智能·科技·安全·全文检索·生活·能源
牛客企业服务7 小时前
AI简历筛选:破解海量简历处理难题
人工智能
粟悟饭&龟波功7 小时前
【GitHub热门项目精选】(2025-12-19)
前端·人工智能·后端·github
诸葛务农7 小时前
类脑智能技术前沿进展及中美类脑智能技术比对
人工智能
LiYingL7 小时前
ChartCap:利用大型数据集和新的评估指标抑制图表标题幻觉
人工智能
有来有去95277 小时前
vllm推理服务指标监控看板搭建手册
人工智能·vllm
流浪法师127 小时前
MyPhishing-Web:AI 驱动的钓鱼邮件检测可视化平台
前端·人工智能