OSError: Can‘t load tokenizer for ‘bert-base-uncased‘.

一、具体报错:

报错如下:
OSError: Can't load tokenizer for 'bert-base-uncased'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'bert-base-uncased' is the correct path to a dir

二、报错原因:

模型调用bert时,由于huggingface有墙导致模型无法下载

三、 解决方法:

1、通过镜像站下载

直接命令行通过huggingface镜像运行脚本,从而下载对应bert模型权重
HF_ENDPOINT=https://hf-mirror.com python 模型脚本.py

与之相同,通过设置环境变量也可以,以linux为例
export HF_ENDPOINT=https://hf-mirror.com

2、直接下载权重

地址https://huggingface.co/google-bert/bert-base-uncased/tree/main
镜像地址https://hf-mirror.com/google-bert/bert-base-uncased/tree/main
下载内容

xml 复制代码
config.json
pytorch_model.bin
tokenizer.json
tokenizer_config.json
vocab.txt

将对应文件放入一个文件夹内,如bert-base-uncased;查看报错所在的文件具体位置,以及对应引用模型的位置


tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')

from_pretrained()中的内容换成模型所在文件夹的路径,建议填写绝对路径
tokenizer = BertTokenizer.from_pretrained('./bert-base-uncased')

相关推荐
就是一顿骚操作4 分钟前
神经网络可解释性积木:从特征可视化到归因地图
人工智能·深度学习·神经网络
kisshyshy5 分钟前
从无崖子到OpenAI:大模型间的“传功”,动了谁的奶酪?
人工智能·深度学习·设计模式
LadenKiller8 分钟前
2026年量化工具增量,放回回测模拟实盘阶段判断
人工智能·python
用户471844407758 分钟前
强化学习-从零定制强化学习环境:GridWorld 悬崖行走 + PPO 训练全解析
人工智能
不爱记笔记9 分钟前
音视频内容如何纳入Obsidian知识库?分享一套完整的输入层解决方案
人工智能·ai·chatgpt·音视频·知识库·知识管理·obsidian
茶马古道的搬运工9 分钟前
AI 深度技能之-解读OpenHuman(一)- Rust 写的个人 Agent 操作系统
人工智能
集芯微电科技有限公司10 分钟前
各种大小尺寸TFT-LCD面板供电偏压电源方案IC
人工智能·单片机·嵌入式硬件·神经网络·生成对抗网络
renhongxia111 分钟前
Scaling Law撞墙了吗?大模型的“规模法则”走向何方
人工智能·深度学习·机器学习·架构·机器人
东风破_12 分钟前
Agent 一次返回多个 Tool Call,应该并行还是顺序执行?
人工智能
问商十三载14 分钟前
大模型GEO内容更新频率:3个节奏规律提收录权重,零成本提30%引用率附更新计划表
前端·人工智能·机器学习