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

NLP学习与踩坑记录(持续更新版)

NLP学习与踩坑记录(持续更新版)

  • OSError: Can't load tokenizer for 'bert-base-uncased'.
  • google.protobuf.message.DecodeError: Error parsing message
  • Deepspeed

本博客记录了博主在学习NLP时遇到了各种各样的问题与解决方法,供大家参考,希望踩过的坑不踩第二次!

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

tokenizer = BertTokenizer.from_pretrained("bert-base-uncased", truncation_side=truncation_side)

博主在调用上述代码时出现此报错,原因是在国内因为网络问题无法下载huggingface上的模型。
解决办法一:检查自己的网络,在国内需要使用VPN保证可以访问huggingface,然后重新运行代码。若不行,将模型下载到本地,再重新运行代码。

huggingface-cli download --resume-download google-bert/bert-base-cased --local-dir /home/user/bert-base-cased

解决办法二:使用modelscope上的镜像,速度较快,但可能存在一些huggingface上的模型modelscope上没有。

# pip install modelscope
from modelscope.hub.snapshot_download import snapshot_download
llm = snapshot_download('AI-ModelScope/bert-base-uncased')
tokenizer = BertTokenizer.from_pretrained(llm, truncation_side=truncation_side)

解决办法三:Colab下载转移至Google Drive上,再从Google Drive上下载。

google.protobuf.message.DecodeError: Error parsing message

原因是通过git clone命令直接下载,并没有下载到正确的模型参数文件,只是一个文本文档,解决方法是下载huggingface上的模型需要使用huggingface-cli工具。

# 错误的下载方式
git clone https://huggingface.co/bert-base-uncased
# 正确的下载方式
pip install huggingface_hub
huggingface-cli download --resume-download [model_name] --local-dir [local path] 
# eg: huggingface-cli download --resume-download google-bert/bert-base-cased --local-dir /home/user/

Deepspeed

  • Deepspeed 在训练代码中如果单卡无法加载,初始化需要用init context,参考huggingface的trainer(training argument在模型加载前)https://huggingface.co/docs/transformers/v4.34.1/en/main_classes/deepspeed#constructing-massive-models
  • 数据并行data parallelism (zero3 cuts model horizontally)、流水线并行pipeline parallelism (cuts model vertically)
    https://huggingface.co/docs/transformers/v4.35.2/en/perf_train_gpu_many#zero-data-parallelism–pipeline-parallelism–tensor-parallelism
  • zero++ 优化通信策略 https://www.deepspeed.ai/tutorials/zeropp/#three-components-of-zero
http://www.lryc.cn/news/382759.html

相关文章:

  • Java也能做OCR!SpringBoot 整合 Tess4J 实现图片文字识别
  • 微信小程序常用标签及其用法
  • 开发查询订单信息fastGPT智能体工作流 将工作流接入到人工客服系统
  • Flink集群运行模式
  • XSS 安全漏洞介绍及修复方案
  • 基于STM32的智能仓库管理系统
  • LeetCode —— 只出现一次的数字
  • python遍历文件夹中所有图片
  • 速盾:DDOS能打死高防ip吗?
  • 3dsMax怎样让渲染效果更逼真出色?三套低中高参数设置
  • Android的OverlayFS原理与作用
  • 奇点临近:人类与智能时代的未来
  • NAS教程丨铁威马如何登录 SSH终端?
  • 2024-06-24 百度地图的使用及gps定位坐标获取
  • Python二级考试试题②
  • 安装和使用nvm安装Nodejs
  • 非遗!四川省21市非遗大师工作室申报认定条件程序和认定补贴经费支持(管理办法)
  • uni-app系列:uni.navigateTo传值跳转
  • 6.3万美刀BTC的车还能上吗?
  • 在 Vue 3 中设置 `@` 指向根目录的方法汇总
  • 基于 NXP LS1046 +FPGA系列 CPCI 架构轨道交通专用板卡
  • 快速上手 Spring Boot:基础使用详解
  • react学习——08三点运算符
  • 腾讯云OpenCloudOS系统上安装MySQL
  • C++ - 介绍enum的使用
  • Qt 信号与槽的使用详解 - 多种绑定形式、同步异步、Lambda表达式等
  • Harbor本地仓库搭建002_Harbor负载均衡节点搭建_nginx安装配置_harbor安装---分布式云原生部署架构搭建002
  • 《单元测试之道Java版——使用JUnit》学习笔记汇总
  • 项目实训-vue(十一)
  • 计算机网络-BGP路由负载分担