本地加载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)
相关推荐
Warren2Lynch12 小时前
AI 驱动的 UML 图表支持全景指南
人工智能·架构·uml
小鱼~~13 小时前
什么是父进程
人工智能
找了一圈尾巴13 小时前
OpenClaw技能实战:Experience Distiller 让AI从错误中自我进化
人工智能·openclaw
蕤葳-13 小时前
AI项目经验在招聘中的作用
人工智能
devpotato13 小时前
人工智能(四)- Function Calling 核心原理与实战
java·人工智能
进击的野人13 小时前
MCP协议:让AI应用像插USB一样连接外部世界
人工智能·agent·mcp
清空mega13 小时前
动手学深度学习——SSD
人工智能·深度学习
tinochen13 小时前
我用 OpenClaw 搭了一套全自动 AI 行业简报系统,每天零干预推送到飞书
人工智能
何陋轩13 小时前
OpenAI Codex深度解析:终端里的AI代码特工,一个指令重构整个项目
人工智能·面试
jarvisuni13 小时前
三大编程智能体的RULES和SKILLS规范!
人工智能·ai编程