本地加载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)
相关推荐
AKAMAI6 小时前
Akamai Cloud客户案例 | Avesha 在 Akamai 云上扩展 Kubernetes 解决方案
人工智能·云计算
wasp5207 小时前
AgentScope Java 核心架构深度解析
java·开发语言·人工智能·架构·agentscope
智算菩萨7 小时前
高效多模态大语言模型:从统一框架到训练与推理效率的系统化理论梳理
大数据·人工智能·多模态
free-elcmacom7 小时前
深度学习<4>高效模型架构与优化器的“效率革命”
人工智能·python·深度学习·机器学习·架构
liliangcsdn7 小时前
python模拟beam search优化LLM输出过程
人工智能·python
算法与编程之美7 小时前
深度学习任务中的多层卷积与全连接输出方法
人工智能·深度学习
Deepoch7 小时前
具身智能产业新范式:Deepoc开发板如何破解机器人智能化升级难题
人工智能·科技·机器人·开发板·具身模型·deepoc
浪子不回头4158 小时前
SGLang学习笔记
人工智能·笔记·学习
飞哥数智坊8 小时前
TRAE 国内版 SOLO 全放开
人工智能·ai编程·trae
落叶,听雪9 小时前
AI建站推荐
大数据·人工智能·python