浦语大模型趣味 Demo
作业:
1.使用 InternLM-Chat-7B 模型生成 300 字的小故事(需截图)
因为命令行版本和web 版本本质没什么区别,所有在web端令InternLM生成小故事:
2.熟悉 hugging face 下载功能,使用 huggingface_hub
python 包,下载 InternLM-20B
的 config.json 文件到本地
首先创建huggingface_downloads.py 使用以下代码:
from huggingface_hub import hf_hub_download
model = "internlm/internlm2-chat-20b"
output_dir = "./class2Homework/config.json"
hf_hub_download(repo_id=model, filename="config.json", repo_type="model",cache_dir = output_dir)
hf_hub_download 函数repo_id 是huggingface 仓库名称 filename是要下载的文件,repo_type选择为model cache_dir 为下载本地文件路径
具体参数请查看:https://huggingface.co/docs/huggingface_hub/main/en/package_reference/file_download#huggingface_hub.hf_hub_download
之后运行文件:
最后在output_dir路径下下载目标config.json文件