手机网站快速排名,那些网站可以做h5,深圳网站营销seo费用,旅游网站网页设计方案NLP学习与踩坑记录#xff08;持续更新版#xff09; OSError: Cant load tokenizer for bert-base-uncased.google.protobuf.message.DecodeError: Error parsing messageDeepspeed 本博客记录了博主在学习NLP时遇到了各种各样的问题与解决方法#xff0c;供大家参考#… NLP学习与踩坑记录持续更新版 OSError: Cant load tokenizer for bert-base-uncased.google.protobuf.message.DecodeError: Error parsing messageDeepspeed 本博客记录了博主在学习NLP时遇到了各种各样的问题与解决方法供大家参考希望踩过的坑不踩第二次
OSError: Can’t load tokenizer for ‘bert-base-uncased’.
tokenizer BertTokenizer.from_pretrained(bert-base-uncased, truncation_sidetruncation_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_sidetruncation_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的trainertraining 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-parallelismzero 优化通信策略 https://www.deepspeed.ai/tutorials/zeropp/#three-components-of-zero