本地加载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)
相关推荐
gorgeous(๑>؂<๑)3 小时前
【ICLR26-金玥明-新国立】MedAgent-Pro:通过推理智能体工作流实现基于证据的多模态医疗诊断
人工智能
hqyjzsb3 小时前
企业AI人才库的搭建体系与长效运营管理方案
人工智能·学习·职场和发展·创业创新·学习方法·业界资讯·改行学it
码农小韩3 小时前
AIAgent应用开发——大模型理论基础与应用(五)
人工智能·python·提示词工程·aiagent
拔刀能留住落樱吗、3 小时前
AI 落地避坑实战(2026 最新):200 + 项目复盘,数据 + 方案 + 代码思路,少亏 50 万
人工智能
龙山云仓3 小时前
No160:AI中国故事-对话耿恭——孤城坚守与AI韧性:极端环境与信念之光
大数据·人工智能·机器学习
Dcs3 小时前
花 200 美刀买“黑盒”?Claude Code 这波更新,把程序员当傻子了吧…
人工智能·ai编程·claude
Mr_Lucifer4 小时前
成本大幅降低、Agent效率显著提升:CodeFlicker 接入 MiniMax M2.5 与 GLM-5
人工智能·ai编程·产品
Jonathan Star4 小时前
Ant Design (antd) Form 组件中必填项的星号(*)从标签左侧移到右侧
人工智能·python·tensorflow
挂科边缘4 小时前
YOLOv12环境配置,手把手教你使用YOLOv12训练自己的数据集和推理(附YOLOv12网络结构图),全文最详细教程
人工智能·深度学习·yolo·目标检测·计算机视觉·yolov12
deep_drink4 小时前
【论文精读(三)】PointMLP:大道至简,无需卷积与注意力的纯MLP点云网络 (ICLR 2022)
人工智能·pytorch·python·深度学习·3d·point cloud