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

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

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

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

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

python 复制代码
tokenizer = BertTokenizer.from_pretrained("bert-base-uncased", truncation_side=truncation_side)

博主在调用上述代码时出现此报错,原因是在国内因为网络问题无法下载huggingface上的模型。

解决办法一:检查自己的网络,在国内需要使用VPN保证可以访问huggingface,然后重新运行代码。若不行,将模型下载到本地,再重新运行代码。

bash 复制代码
huggingface-cli download --resume-download google-bert/bert-base-cased --local-dir /home/user/bert-base-cased

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

python 复制代码
# 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工具。

bash 复制代码
# 错误的下载方式
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

相关推荐
xzkyd outpaper17 小时前
Android中ViewStub和View有什么区别?
android·开发语言·面试·代码
ergevv10 天前
不同场景下git指令的搭配
git·源代码管理·代码
程序员鱼皮10 天前
会Vibe Coding的同事:我一个人干掉整个技术部!
ai·程序员·互联网·编程·开发·代码
百锦再2 个月前
Git 使用大全:从入门到精通
git·version·版本·代码·分支·code·clone
程序员鱼皮2 个月前
全球首个无限执行的 AI 出现!给我玩爽了
计算机·ai·互联网·agent·代码
程序员鱼皮2 个月前
Claude 4炸裂发布!凭什么敢称宇宙最强编程 AI?
计算机·ai·编程·开发·代码
涤生大数据3 个月前
带你玩转 Flink TumblingWindow:从理论到代码的深度探索
flink·理论·代码·tumblingwindow
技术干货贩卖机3 个月前
0基础 | Proteus电路仿真 | 电机使用
单片机·嵌入式硬件·proteus·代码·0基础·proteus 仿真
码观天工4 个月前
AI与.NET技术实操系列(八):使用Catalyst进行自然语言处理
ai·.net·自然语言·ml.net·catalyst
power-辰南5 个月前
企业级智能对话AI助手(一)技术方案设计
人工智能·自然语言·ner·ai agent·nlu