本地加载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)
相关推荐
波动几何30 分钟前
因果动力学架构技能cda
人工智能
Lucas_coding33 分钟前
【Claude Code Router】 Claude Code 兼容 OpenAI 格式 API, Claude code 接入本地部署模型
人工智能·python
jinanwuhuaguo34 分钟前
(第二十七篇)OpenClaw四月的演化风暴:OpenClaw 2026年4月全版本更新的文明级解读
大数据·人工智能·架构·kotlin·openclaw
测试员周周36 分钟前
【AI测试系统】第5篇:从 Archon 看 AI 工程化落地:为什么"确定性编排+AI 弹性智能"是终局?
人工智能·python·测试
RxGc42 分钟前
微软AI Agent框架深度测评:Microsoft Agent Framework 1.0 vs OpenClaw/Claude企业级能力对比
人工智能·agent
随便写写42 分钟前
第四章 智能体经典范式构建
人工智能
穿过生命散发芬芳44 分钟前
基于CodeBuddy Agent智能体平台构建自己第一个SKILL——相机推荐
人工智能
格林威1 小时前
工业视觉项目:如何与客户有效沟通验收标准?
人工智能·数码相机·计算机视觉·视觉检测·机器视觉·工业相机·视觉项目
zhuiyisuifeng1 小时前
AI新闻配图革命:GPTimage2镜像官网重塑时效与成本
人工智能·gpt
码云数智-大飞1 小时前
本地部署大模型:隐私安全与多元优势一站式解读
运维·网络·人工智能