本地加载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)
相关推荐
啵啵啵鱼6 小时前
Chrome 内存泄漏诊断指南
人工智能
Mirawork7 小时前
AI 低代码建站原理:从自然语言需求到在线应用,拆解 AI 生成网页的完整技术链路
人工智能·低代码·ai·ai编程
xsd202411187 小时前
rea-video开源 AI 视频逆向工具
人工智能
thinking_talk8 小时前
AI 自动诊断慢 SQL 怎么落地:五层能力怎么分,以及生产可用要过哪几道门槛
数据库·人工智能·sql·慢sql
程序猿追8 小时前
HarmonyOS 7 ArkUI 卡片点击分发:点关闭按钮,怎样确保只收起推荐
pytorch·深度学习·harmonyos
码上观世界8 小时前
IndexTTS接入实时交互数字人系统实践
人工智能·实时互动
具身AGI8 小时前
进博会机器人,隔桌对打乒乓球
人工智能·机器人
逐米时代8 小时前
「制造新解法」行业对标方法:借鉴而不照搬的最佳实践
人工智能·算法·制造
小追兵8 小时前
Claude Managed Agents 自托管是什么?企业如何控制 Agent Runtime、Session 与数据?
人工智能
Wellijohn9 小时前
上下文工程实战:把大模型 Agent 从「能跑」做到「上线不掉链子」
人工智能·llm·agent