本地加载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)
相关推荐
Keep_Trying_Go23 分钟前
基于Zero-Shot的目标计数算法详解(Open-world Text-specified Object Counting)
人工智能·pytorch·python·算法·多模态·目标统计
AKAMAI38 分钟前
Akamai 宣布收购功能即服务公司 Fermyon
人工智能·云计算
河南博为智能科技有限公司1 小时前
高集成度国产八串口联网服务器:工业级多设备联网解决方案
大数据·运维·服务器·数据库·人工智能·物联网
光路科技1 小时前
人工智能时代,工业以太网正在“进化”成什么样?
人工智能
翔云 OCR API1 小时前
承兑汇票识别接口技术解析-开发者接口
开发语言·前端·数据库·人工智能·ocr
roman_日积跬步-终至千里1 小时前
【模式识别与机器学习(16)】聚类分析【1】:基础概念与常见方法
人工智能·机器学习
nvd112 小时前
一个简单的GitHub AI Agent 实现指南
人工智能·langchain
阿里云大数据AI技术2 小时前
【新模型速递】PAI-Model Gallery云上一键部署DeepSeek-V3.2模型
人工智能
阿恩.7702 小时前
2026年1月最新计算机、人工智能、经济管理国际会议:选对会议 = 论文成功率翻倍
人工智能·经验分享·笔记·计算机网络·金融·区块链
高-老师2 小时前
WRF模式与Python融合技术在多领域中的应用及精美绘图
人工智能·python·wrf模式