本文包含两个内容:

1.hf加载模型时报错:

ValueError: Connection error, and we cannot find the requested files in the cached path. 

即使是离线加载模型,仍然会报此错误。

2.解决第一个问题后出现:CodeLlamaTokenizer 不存在问题

ValueError: Tokenizer class CodeLlamaTokenizer does not exist or is not currently imported.

解决:

问题1:经过尝试,使用在线加载模型的方法目前还没有解决这个问题;离线加载模型时,只需将模型路径写成绝对路径即可。

tokenizer = AutoTokenizer.from_pretrained("absolute path")
model = AutoModelForCausalLM.from_pretrained("absolute path")

问题2:出现任何分词器不存在的问题,都是Transformers版本不对导致的。

本问题中CodeLlamaTokenizer不存在,是由于Transformers版本过低,升级至4.40.0即可解决。

更多推荐