本地加载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)
相关推荐
PythonPioneer43 分钟前
如何使用AI大语言模型解决生活中的实际小事情?
人工智能·语言模型·生活
阿雄不会写代码1 小时前
图像打标工具/方法的分类和特点说明
人工智能·分类·数据挖掘
tryCbest1 小时前
Python人工智能中scikit-learn模块的使用介绍
人工智能·python·scikit-learn
Akamai中国2 小时前
SharePlay确保最佳游戏体验
人工智能·云原生·云计算
智驱力人工智能3 小时前
工厂智慧设备检测:多模态算法提升工业安全阈值
人工智能·算法·安全·边缘计算·智慧工厂·智能巡航·工厂设备检测
计算机sci论文精选4 小时前
ECCV 2024 论文解读丨具身智能、机器人研究最新突破创先点分享合集
人工智能·科技·深度学习·计算机视觉·机器人·cvpr
大模型真好玩5 小时前
深入浅出LangChain AI Agent智能体开发教程(八)—LangChain接入MCP实现流程
人工智能·python·mcp
R-G-B5 小时前
【15】OpenCV C++实战篇——fitEllipse椭圆拟合、 Ellipse()画椭圆
c++·人工智能·opencv·fitellipse椭圆拟合·ellipse画椭圆·椭圆拟合·绘制椭圆
lll482335 小时前
opencv颜色识别项目:识别水果
人工智能·opencv·计算机视觉
飞哥数智坊6 小时前
Trae vs Cursor:深度体验 Trae 一个月后,我的真实感受
人工智能·cursor·trae