手动从 huggingface 下载模型之后,怎么把模型文件放到指定路径?
我需要在本地运行 chatGLM3,然后我就用下面的代码跑
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm3-6b", trust_remote_code=True)
model = AutoModel.from_pretrained("THUDM/chatglm3-6b", trust_remote_code=True, device='cuda')
model = model.eval()
response, history = model.chat(tokenizer, "你好", history=[])
运行上面的代码,首先会从 huggingface 下载 10GB 左右的模型文件。但是问题来了,huggingface 的下载速度太慢了。所以我就想手动下载:https://huggingface.co/THUDM/chatglm3-6b/tree/main
但是问题在于,huggingface 奇葩的本地目录结构:
╰─➤ fd -a -u pytorch_model | grep chatglm3-6b
/home/pon/.cache/huggingface/hub/models--THUDM--chatglm3-6b/snapshots/e46a14881eae613281abbd266ee918e93a56018f/pytorch_model-00007-of-00007.bin
/home/pon/.cache/huggingface/hub/models--THUDM--chatglm3-6b/snapshots/e46a14881eae613281abbd266ee918e93a56018f/pytorch_model-00003-of-00007.bin
/home/pon/.cache/huggingface/hub/models--THUDM--chatglm3-6b/snapshots/e46a14881eae613281abbd266ee918e93a56018f/pytorch_model-00006-of-00007.bin
/home/pon/.cache/huggingface/hub/models--THUDM--chatglm3-6b/snapshots/e46a14881eae613281abbd266ee918e93a56018f/pytorch_model-00004-of-00007.bin
/home/pon/.cache/huggingface/hub/models--THUDM--chatglm3-6b/snapshots/e46a14881eae613281abbd266ee918e93a56018f/pytorch_model-00001-of-00007.bin
/home/pon/.cache/huggingface/hub/models--THUDM--chatglm3-6b/snapshots/e46a14881eae613281abbd266ee918e93a56018f/pytorch_model.bin.index.json
/home/pon/.cache/huggingface/hub/models--THUDM--chatglm3-6b/snapshots/e46a14881eae613281abbd266ee918e93a56018f/pytorch_model-00002-of-00007.bin
/home/pon/.cache/huggingface/hub/models--THUDM--chatglm3-6b/snapshots/e46a14881eae613281abbd266ee918e93a56018f/pytorch_model-00005-of-00007.bin
/home/pon/.cache/huggingface/hub/models--THUDM--chatglm3-6b/.no_exist/e46a14881eae613281abbd266ee918e93a56018f/pytorch_model.bin
有一串莫名其妙的 snapshots/e46a14881eae613281abbd266ee918e93a56018f
!!!! so, 我手动下载了模型文件之后,我怎么知道要把这些模型文件放哪个路径?上哪知道是 e46a14881eae613281abbd266ee918e93a56018f 还是 e46a14881eae613281abbd266ee918e93a56018w?
贴一个群友的回复(真实性未验证,为什么不验证?因为我换用百度的飞桨了)