本地加载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)
相关推荐
子燕若水2 小时前
Unreal Engine 5中的AI知识
人工智能
极限实验室3 小时前
Coco AI 实战(一):Coco Server Linux 平台部署
人工智能
杨过过儿3 小时前
【学习笔记】4.1 什么是 LLM
人工智能
巴伦是只猫3 小时前
【机器学习笔记Ⅰ】13 正则化代价函数
人工智能·笔记·机器学习
伍哥的传说3 小时前
React 各颜色转换方法、颜色值换算工具HEX、RGB/RGBA、HSL/HSLA、HSV、CMYK
深度学习·神经网络·react.js
大千AI助手3 小时前
DTW模版匹配:弹性对齐的时间序列相似度度量算法
人工智能·算法·机器学习·数据挖掘·模版匹配·dtw模版匹配
AI生存日记4 小时前
百度文心大模型 4.5 系列全面开源 英特尔同步支持端侧部署
人工智能·百度·开源·open ai大模型
LCG元4 小时前
自动驾驶感知模块的多模态数据融合:时序同步与空间对齐的框架解析
人工智能·机器学习·自动驾驶
why技术4 小时前
Stack Overflow,轰然倒下!
前端·人工智能·后端