当前位置: 首页 > news >正文

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
下载内容

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')

http://www.lryc.cn/news/471136.html

相关文章:

  • 中国人寿财险青岛市分公司:专业团队,卓越服务
  • 【SpringCloud】基础问题
  • 牛客网刷题(1)(java之数据类型、数组的创建(静态/动态初始化)、static关键字与静态属性和方法、常用的servlet包、面向对象程序设计方法优点)
  • 电磁干扰(EMI)与电磁兼容性(EMC)【小登培训】
  • 保险行业的智能客服:企业AI助理与知识库的加速效应
  • PSINS工具箱函数介绍——inserrplot
  • 龙蟠科技业绩压力显著:资产负债率持续攀升,产能利用率也不乐观
  • 使用 Spring Cloud 有什么优势?
  • MySQL 日志之 binlog 格式 → 关于 MySQL 默认隔离级别的探讨
  • SQL进阶技巧:Hive如何进行更新和删除操作?
  • nginx安装详解含 自动化编译安装 Debian/Ubuntu/CentOS/RHEL/ROCKY
  • Go编程语言介绍及项目案例
  • 刷爆leetcode Day11 DFS
  • 虚拟机不同网络模式的区别
  • 嵌入式软件 Bug 排查与调试技巧
  • 阿里云环境下用docker搭建redis主从复制
  • STM32 从0开始系统学习 1
  • python-numpy-笔记1
  • 云+AI 时代的 OceanBase
  • 【C++】vector使用详解
  • .NET Core WebApi第5讲:接口传参实现、数据获取流程、204状态码问题
  • 运维面试汇总
  • 学习封装Flutter组件,看这篇就够了
  • 无线麦克风方案芯片DSH32F3024
  • 谷粒商城の秒杀服务
  • 庆祝程序员节:聊一聊编程语言的演变
  • 大模型技术在网络安全领域的应用与发展
  • 基于vite和vue3、 eslint、prettier、stylelint、husky规范
  • git push到远程怎么回退
  • Web保存状态的手段(Application的使用)