OSError: Can‘t load tokenizer for ‘bert-base-chinese‘

文章目录

  • [OSError: Can't load tokenizer for 'bert-base-chinese'](#OSError: Can't load tokenizer for 'bert-base-chinese')

OSError: Can't load tokenizer for 'bert-base-chinese'

1.问题描述

使用from_pretrained()函数从预训练的权重中加载模型时报错:

OSError: Can't load tokenizer for 'bert-base-chinese'. 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-chinese' is the correct path to a directory containing allrelevant files for a BertTokenizer tokenizer.

原因:主机或服务器 不能访问https://huggingface.co/页面,因此不能下载相应的权重。

2.解决办法

将权重文件下载到本地或服务器,使用本地权重文件实现加载,而不是在线下载。

  • 进入官网,Models页面,下载对应的Bert模型的权重。
  • 将下载的权重文件,放到某个文件夹下(加载路径的位置)
  • 修改权重文件的加载路径,也就是from_pretrained()函数里面的权重文件路径。注意:必须是绝对路径

成功解决!!!

😃😃😃

相关推荐
lancyu1 小时前
零基础AI应用编程开发入门 | 吴恩达Prompt工程极简通关指南:新手从零学会工业级提示词开发(可直接复用代码)
人工智能·深度学习·机器学习
LaughingZhu1 小时前
Product Hunt 每日热榜 | 2026-08-03
人工智能·经验分享·深度学习·神经网络·产品运营
湘美书院--湘美谈教育4 小时前
AI时代的奥德赛:算法星空,寻找精神归航
大数据·人工智能·深度学习·机器学习·生活
搞科研的小刘选手4 小时前
【昌吉学院主办】第三届大数据、神经网络与深度学习研讨会(BDNNDL 2026)
大数据·深度学习·神经网络·学术会议·会议推荐
FriendshipT5 小时前
Ubuntu 20.04 下使用 Ollama 本地部署 AI 大模型
linux·人工智能·python·深度学习·ubuntu
m沐沐7 小时前
【机器学习】朴素贝叶斯算法:从贝叶斯定理到手写数字识别实战
人工智能·深度学习·算法·机器学习·计算机视觉·手写数字·数字识别
大鱼>7 小时前
DSPy:LLM程序自动编译与提示词优化
开发语言·人工智能·python·深度学习
DogDaoDao7 小时前
VVC 帧间编码分区加速方法
深度学习·音视频·视频编解码·h266·vvc·预测编码·帧间编码
Lee_jerome7 小时前
python神经网络编程入门(二十)——RNN LSTM 数学原理与结构拆解
深度学习·numpy·lstm·参数量·sigmoid·tanh·门控机制
满怀冰雪8 小时前
15-Paddle 高层 API 入门:paddle.Model 的训练与评估流程
人工智能·python·深度学习·机器学习·paddle