本地加载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)
相关推荐
像风一样自由20207 分钟前
17.推理框架横评:vLLM / TGI / TensorRT-LLM / SGLang 全面对比
人工智能·大模型·vllm·sglang
walnut_oyb10 分钟前
CVPR 2026|VisRes Bench:视觉语言模型视觉推理能力评估
人工智能·语言模型·自然语言处理
网教盟人才服务平台15 分钟前
第223期方班学术研讨厅成功举办
人工智能
lauo21 分钟前
ibbot手机:从赛博攻防到Token经济的AI终端革命
人工智能·智能手机
私人珍藏库38 分钟前
【Android】BotHub-多模型AI机器人聚合库-内置免费模型
android·人工智能·智能手机·app·工具·多功能
老马聊技术1 小时前
AI对话功能之SpringBoot整合Vue3
vue.js·人工智能·spring boot·后端
阿寻寻1 小时前
【人工智能学习260612-软件测试篇】小工具实现 [特殊字符] Prompt工程 + RAG思路 + API调用 + 自动化测试
人工智能·功能测试·学习·prompt
甲维斯1 小时前
测一波Kimi K2.7,消耗一周配额!
前端·人工智能·游戏开发
石山代码1 小时前
给照片装上 AI 引擎:ACDSee 2025 安装详细步骤
人工智能
chase_my_dream1 小时前
A-LOAM中scanRegistration.cpp详细讲解
c++·人工智能·自动驾驶