使用modelscope下载huggingface模型
设置国内镜像
export HF_ENDPOINT=https://hf-mirror.com
修改默认cache下载路径
export MODELSCOPE_CACHE=/root/volumes/modelscope
下载模型
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
if __name__ == '__main__':
# input = '程序员脱发用什么洗发水'
model_id = '01ai/Yi-34B-Chat'
pipe = pipeline(Tasks.text_generation, model=model_id)
# 可以在 pipe 中输入 max_length, top_k, top_p, temperature 等生成参数
# print(pipe(input, max_length=512))
下载单个pth文件
from modelscope.hub.file_download import model_file_download
model_dir = model_file_download(model_id='AI-ModelScope/rwkv-4-world',file_path='RWKV-4-World-CHNtuned-7B-v1-20230709-ctx4096.pth',revision='v1.0.0')