本地加载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)
相关推荐
洛宇6 小时前
一个口语 skill,灵感居然来自2021年的那个夏天
人工智能·程序员·github
微擎应用7 小时前
智能售货柜公众号管理系统平台
大数据·人工智能
IT_陈寒7 小时前
Vite打包时遇到的坑,原来问题出在这里
前端·人工智能·后端
星辰AI7 小时前
多模态记忆:让 AI Agent 记忆各种类型的信息
人工智能·ai·语言模型
jiayong237 小时前
AI架构师面试题库 - 完整汇总文档
人工智能·面试·职场和发展
后端小肥肠7 小时前
效率狂飙9000%!Codex + HyperFrames 让一篇文章 5 分钟变视频
人工智能·aigc·agent
阿里云大数据AI技术7 小时前
最佳实践:用 EMR Serverless StarRocks AI Function 实现金融行业文本分类
人工智能
miaowmiaow8 小时前
PSD2Code 近期更新与深度解析:从设计稿到生产级代码的完整技术栈
前端·人工智能·ai编程
云烟成雨TD8 小时前
Spring AI 1.x 系列【33】RAG Advisor 组件与四大分层架构
java·人工智能·spring
lifallen8 小时前
第一章 Agent 为什么会出现
人工智能·ai·ai编程