本地加载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 小时前
EWC/KD/ILR/PL
人工智能
100个铜锣烧8 小时前
高级提示技术:Chain-of-Thought与ReAct——让大模型学会“思考”和“行动”
人工智能·大模型·提示词工程
JackHCC8 小时前
快手OneRetrieval:可编辑生成式电商召回
人工智能·机器学习
前端之虎陈随易9 小时前
编程语言级别的Skill市场,AI Agent 的未来形态
前端·vue.js·人工智能·typescript·node.js
QiLinkOS9 小时前
第三视觉理解徐玉生与他的商业活动(30)
大数据·c++·人工智能·算法·开源协议
武汉唯众智创9 小时前
当汉字成为心理CT:AI汉字联想投射分析的技术实现与心理评估价值
人工智能·ai心理健康·ai心理评估·本土化心理测评·校园心理健康解决方案·ai心理监测·多模态情绪模型
Longvox9 小时前
Agent为什么会死循环?
人工智能·ai编程
陈天伟教授10 小时前
FreeCAD 启动后小窗口闪现即退的解决思路
人工智能·机器人·工业设计
酒旅Agent开发实战10 小时前
AI 旅行规划助手如何接入真实酒旅数据:从自然语言到酒店预订的全流程 MCP 实战
人工智能·ai·旅游·skill·酒店api·机票api
workflower10 小时前
设备单元级(L1)实施路径
人工智能·线性代数·矩阵·机器人·开源