基础:
- 使用 InternLM-Chat-7B 模型生成 300 字的小故事。
详情可以见我的完成撰写文章:https://blog.51cto.com/morcake/9105322
上图为进入的开始界面,下面即可进行问答:
- 熟悉 hugging face 下载功能,使用
huggingface_hub
python 包,下载InternLM-20B
的 config.json 文件到本地(需截图下载过程)。
使用 Hugging Face 官方提供的 huggingface-cli
命令行工具。安装依赖:
pip install -U huggingface_hub
然后新建 python 文件,填入以下代码,运行即可。
- resume-download:断点续下
- local-dir:本地存储路径。(linux 环境下需要填写绝对路径)
import os
# 下载模型
os.system('huggingface-cli download --resume-download internlm/internlm-chat-7b --local-dir your_path')
以下内容将展示使用 huggingface_hub
下载模型中的部分文件:
import os
from huggingface_hub import hf_hub_download # Load model directly
hf_hub_download(repo_id="internlm/internlm-7b", filename="config.json")
下面使用镜像是个参考:
HF_ENDPOINT=https://hf-mirror.com python your_script.py
export HF_ENDPOINT=https://hf-mirror.com
进阶
- 完成浦语·灵笔的图文理解及创作部署(需截图)
详情可以见我的完成撰写文章:https://blog.51cto.com/morcake/9118470
以提示词“又见敦煌”来输入:
- 完成 Lagent 工具调用 Demo 创作部署(需截图)
详情可以见我的完成撰写文章:https://blog.51cto.com/morcake/9105636
在 Web 页面选择 InternLM模型,等待模型加载完毕后,输入数学问题, InternLM-Chat-7B 模型理解题意生成解此题的 Python 代码,Lagent 调度送入 Python 代码解释器求出该问题的解:
附
大模型介绍:
pip 换源
临时使用镜像源安装,如下所示:some-package 为你需要安装的包名:
pip install -i https://mirrors.cernet.edu.cn/pypi/web/simple some-package
设置pip默认镜像源,升级 pip 到最新的版本 (>=10.0.0) 后进行配置,如下所示:
python -m pip install --upgrade pip
pip config set global.index-url https://mirrors.cernet.edu.cn/pypi/web/simple
如果您的 pip 默认源的网络连接较差,临时使用镜像源升级 pip:
python -m pip install -i https://mirrors.cernet.edu.cn/pypi/web/simple --upgrade pip
镜像站提供了 Anaconda 仓库与第三方源(conda-forge、msys2、pytorch 等),各系统都可以通过修改用户目录下的 .condarc
文件来使用镜像站。
不同系统下的 .condarc
目录如下:
Linux
:${HOME}/.condarc
macOS
:${HOME}/.condarc
Windows
:C:\Users\<YourUserName>\.condarc
注意:Windows
用户无法直接创建名为 .condarc
的文件,可先执行 conda config --set show_channel_urls yes
生成该文件之后再修改。
快速配置:
cat <<'EOF' > ~/.condarc
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
EOF
- Hugging Face
使用 Hugging Face 官方提供的 huggingface-cli 命令行工具
- ModelScope
使用 modelscope 中的 snapshot_download 函数下载模型,第一个参数为模型名称,参数 cache_dir 为模型的下载路径。
- OpenXLab
OpenXLab 可以通过指定模型仓库的地址,以及需要下载的文件的名称,文件所需下载的位置等,直接下载模型权重文件。
标签:cn,mirrors,Work,huggingface,智能,InternLM,https,edu,pip From: https://blog.51cto.com/morcake/9134487