本地加载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)
相关推荐
张拭心1 小时前
Cursor 又偷偷更新,这个功能太实用:Visual Editor for Cursor Browser
前端·人工智能
吴佳浩1 小时前
大模型 MoE,你明白了么?
人工智能·llm
Blossom.1183 小时前
基于Embedding+图神经网络的开源软件供应链漏洞检测:从SBOM到自动修复的完整实践
人工智能·分布式·深度学习·神经网络·copilot·开源软件·embedding
t198751283 小时前
电力系统经典节点系统潮流计算MATLAB实现
人工智能·算法·matlab
万悉科技3 小时前
比 Profound 更适合中国企业的GEO产品
大数据·人工智能
mqiqe3 小时前
vLLM(vLLM.ai)生产环境部署大模型
人工智能·vllm
V1ncent Chen3 小时前
机器是如何“洞察“世界的?:深度学习
人工智能·深度学习
AI营销前沿3 小时前
中国AI营销专家深度解析:谁在定义AI营销的未来?
人工智能
前端大卫4 小时前
【重磅福利】学生认证可免费领取 Gemini 3 Pro 一年
前端·人工智能
汽车仪器仪表相关领域4 小时前
LambdaCAN:重构专业空燃比测量的数字化范式
大数据·人工智能·功能测试·安全·重构·汽车·压力测试