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

相关推荐
第一个传播学7 天前
生化危机4重制版修改器下载及其用法解析
代码
SeaTunnel11 天前
从 Python Script 地狱到标准化数据集成框架
大数据·开发语言·python·程序员·代码·seatunnel
向哆哆13 天前
【Bug已解决】Codex cli model output rendered truncated 解决方案
调试·codex·报错解决
向哆哆13 天前
【Bug已解决】Assistant reprocesses previous prompt. 解决方案
调试·codex·报错解决
向哆哆13 天前
【Bug已解决】Suggestion: monetize this MCP server with x402 micropayments 解决方案
调试·codex·报错解决
向哆哆14 天前
【Bug已解决】False positive cybersecurity flag. 解决方案
调试·codex·报错解决
向哆哆14 天前
【Bug已解决】Feature Request: Organize Scheduled Tasks with Tags or Categories 解决方案
调试·codex·报错解决
向哆哆16 天前
【Bug已解决】codex: 配置文件解析错误 — CodeX CLI 配置格式无效解决方案
cli·codex·报错解决
向哆哆16 天前
【Bug已解决】codex: 大文件处理失败 — CodeX CLI 无法读取超大文件解决方案
cli·codex·报错解决
向哆哆16 天前
【Bug已解决】codex: 输出编码乱码 — CodeX CLI 文本显示乱码解决方案
cli·codex·报错解决