1 大模型及 InternLM 模型简介
1.1 什么是大模型?
大模型=大语料+大算力+大模型参数
大模型的优势在于其能够捕捉和理解数据中更为复杂、抽象的特征和关系。书读三遍,其义自见
大模型的应用和发展也需要在性能、成本和道德等多个方面进行权衡和考量。
1.2 InternLM 模型全链条开源
InternLM:
开源的轻量级训练框架。
InternLM-7B
和 InternLM-20B:
基于 InternLM
训练框架,上海人工智能实验室已经发布的两个开源的预训练模型。
Lagent:轻量级、开源的基于大语言模型的智能体(agent)框架。
浦语·灵笔:基于书生·浦语大语言模型研发的视觉-语言大模型,能够实现图像到文本、文本到图像的双向转换。
2 InternLM-Chat-7B 智能对话 Demo
2.1 环境准备
进入 conda
环境之后,使用以下命令从本地克隆一个已有的 pytorch 2.0.1
的环境
bash # 请每次使用 jupyter lab 打开终端时务必先执行 bash 命令进入 bash 中 bash /root/share/install_conda_env_internlm_base.sh internlm-demo # 执行该脚本文件来安装项目实验环境
屏幕输出:
./pkgs/libnpp-11.7.4.75-0/lib/libnppial.so.11 ./pkgs/libnpp-11.7.4.75-0/lib/libnppc.so.11.7.4.75 ./pkgs/libnpp-11.7.4.75-0/lib/libnppif.so.11.7.4.75 ./pkgs/libnpp-11.7.4.75-0/lib/libnpps.so.11.7.4.75 ./pkgs/libnpp-11.7.4.75-0/lib/libnppial.so.11.7.4.75 ./pkgs/libnpp-11.7.4.75-0/lib/libnppist.so.11 ./pkgs/libnpp-11.7.4.75-0/lib/libnppist.so.11.7.4.75 ./pkgs/libnpp-11.7.4.75-0/lib/libnppim.so.11 ./pkgs/libnpp-11.7.4.75-0/lib/libnppisu.so.11.7.4.75 ./pkgs/libnpp-11.7.4.75-0/lib/libnppim.so.11.7.4.75 ./pkgs/libnpp-11.7.4.75-0/lib/libnppig.so.11 ./pkgs/libnpp-11.7.4.75-0/lib/libnppc.so.11 ./pkgs/libnpp-11.7.4.75-0/lib/libnppif.so.11 ./pkgs/libnpp-11.7.4.75-0/info/ ./pkgs/libnpp-11.7.4.75-0/info/files ./pkgs/libnpp-11.7.4.75-0/info/paths.json ./pkgs/libnpp-11.7.4.75-0/info/index.json ./pkgs/libnpp-11.7.4.75-0/info/git ./pkgs/libnpp-11.7.4.75-0/info/repodata_record.json ./pkgs/libnpp-11.7.4.75-0/info/about.json ---------- start create the new conda env: internlm-demo Source: /share/conda_envs/internlm-base Destination: /root/.conda/envs/internlm-demo Packages: 96 Files: 0 Downloading and Extracting Packages: Downloading and Extracting Packages: Preparing transaction: done Verifying transaction: done Executing transaction: done # # To activate this environment, use # # $ conda activate internlm-demo # # To deactivate an active environment, use # # $ conda deactivate Finised! Now you can use your environment by typing: conda activate internlm-demo (base) root@intern-studio-069640:~#View Code
然后使用以下命令激活环境
conda activate internlm-demo
屏幕输出:
(base) root@intern-studio-069640:~# conda activate internlm-demo (internlm-demo) root@intern-studio-069640:~#View Code
并在环境中安装运行 demo 所需要的依赖。
# 升级pip python -m pip install --upgrade pip pip install modelscope==1.9.5 pip install transformers==4.35.2 pip install streamlit==1.24.0 pip install sentencepiece==0.1.99 pip install accelerate==0.24.1
屏幕输出:
(internlm-demo) root@intern-studio-069640:~# # 升级pip (internlm-demo) root@intern-studio-069640:~# python -m pip install --upgrade pip Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Requirement already satisfied: pip in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (23.3.1) Collecting pip Downloading https://pypi.tuna.tsinghua.edu.cn/packages/8a/6a/19e9fe04fca059ccf770861c7d5721ab4c2aebc539889e97c7977528a53b/pip-24.0-py3-none-any.whl (2.1 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 5.8 MB/s eta 0:00:00 Installing collected packages: pip Attempting uninstall: pip Found existing installation: pip 23.3.1 Uninstalling pip-23.3.1: Successfully uninstalled pip-23.3.1 Successfully installed pip-24.0 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv (internlm-demo) root@intern-studio-069640:~# (internlm-demo) root@intern-studio-069640:~# pip install modelscope==1.9.5 Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting modelscope==1.9.5 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ac/05/75b5d750608d7354dc3dd023dca7101e5f3b4645cb3e5b816536d472a058/modelscope-1.9.5-py3-none-any.whl (5.4 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.4/5.4 MB 10.9 MB/s eta 0:00:00 Collecting addict (from modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6a/00/b08f23b7d7e1e14ce01419a467b583edbb93c6cdb8654e54a9cc579cd61f/addict-2.4.0-py3-none-any.whl (3.8 kB) Collecting attrs (from modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e0/44/827b2a91a5816512fcaf3cc4ebc465ccd5d598c45cefa6703fcf4a79018f/attrs-23.2.0-py3-none-any.whl (60 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.8/60.8 kB 875.6 kB/s eta 0:00:00 Collecting datasets<=2.13.0,>=2.8.0 (from modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/17/d8/f808e32ed7fa86617b9ac7a37b7dcff894c839108c4871cc33ffc4e65b7d/datasets-2.13.0-py3-none-any.whl (485 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 485.6/485.6 kB 4.9 MB/s eta 0:00:00 Collecting einops (from modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/29/0b/2d1c0ebfd092e25935b86509a9a817159212d82aa43d7fb07eca4eeff2c2/einops-0.7.0-py3-none-any.whl (44 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 44.6/44.6 kB 3.4 MB/s eta 0:00:00 Requirement already satisfied: filelock>=3.3.0 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from modelscope==1.9.5) (3.13.1) Collecting gast>=0.2.2 (from modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fa/39/5aae571e5a5f4de9c3445dae08a530498e5c53b0e74410eeeb0991c79047/gast-0.5.4-py3-none-any.whl (19 kB) Requirement already satisfied: numpy in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from modelscope==1.9.5) (1.26.2) Collecting oss2 (from modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d5/63/b6c355af7f04a8a1d5759fa6fc47539e25ef8e6f2745372a242fdadcac65/oss2-2.18.4.tar.gz (278 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 278.1/278.1 kB 1.7 MB/s eta 0:00:00 Preparing metadata (setup.py) ... done Collecting pandas (from modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b3/b3/3102c3a4abca1093e50cfec2213102a1c65c0b318a4431395d0121e6e690/pandas-2.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.0 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.0/13.0 MB 6.7 MB/s eta 0:00:00 Requirement already satisfied: Pillow>=6.2.0 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from modelscope==1.9.5) (10.0.1) Collecting pyarrow!=9.0.0,>=6.0.0 (from modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d4/ca/ef67abb77f9dd51a0d3ff7fcebff58296068a046d7da352b9548070005ed/pyarrow-15.0.0-cp310-cp310-manylinux_2_28_x86_64.whl (38.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 38.3/38.3 MB 13.2 MB/s eta 0:00:00 Collecting python-dateutil>=2.1 (from modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/36/7a/87837f39d0296e723bb9b62bbb257d0355c7f6128853c78955f57342a56d/python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 kB 4.0 MB/s eta 0:00:00 Collecting pyyaml (from modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/29/61/bf33c6c85c55bc45a29eee3195848ff2d518d84735eb0e2d8cb42e0d285e/PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (705 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 705.5/705.5 kB 3.0 MB/s eta 0:00:00 Requirement already satisfied: requests>=2.25 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from modelscope==1.9.5) (2.31.0) Collecting scipy (from modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f5/aa/8e6071a5e4dca4ec68b5b22e4991ee74c59c5d372112b9c236ec1faff57d/scipy-1.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.4 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 38.4/38.4 MB 7.4 MB/s eta 0:00:00 Requirement already satisfied: setuptools in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from modelscope==1.9.5) (68.0.0) Collecting simplejson>=3.3.0 (from modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/cb/b6/ed513a0adc3e2c9654864ffb68266dcab5720d5653428d690e7e4fb32a6c/simplejson-3.19.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (137 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 137.9/137.9 kB 2.6 MB/s eta 0:00:00 Collecting sortedcontainers>=1.5.9 (from modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/32/46/9cb0e58b2deb7f82b84065f37f3bffeb12413f947f9388e4cac22c4621ce/sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB) Collecting tqdm>=4.64.0 (from modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2a/14/e75e52d521442e2fcc9f1df3c5e456aead034203d4797867980de558ab34/tqdm-4.66.2-py3-none-any.whl (78 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.3/78.3 kB 838.7 kB/s eta 0:00:00 Requirement already satisfied: urllib3>=1.26 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from modelscope==1.9.5) (1.26.18) Collecting yapf (from modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/66/c9/d4b03b2490107f13ebd68fe9496d41ae41a7de6275ead56d0d4621b11ffd/yapf-0.40.2-py3-none-any.whl (254 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 254.7/254.7 kB 374.4 kB/s eta 0:00:00 Collecting dill<0.3.7,>=0.3.0 (from datasets<=2.13.0,>=2.8.0->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/be/e3/a84bf2e561beed15813080d693b4b27573262433fced9c1d1fea59e60553/dill-0.3.6-py3-none-any.whl (110 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 110.5/110.5 kB 744.8 kB/s eta 0:00:00 Collecting xxhash (from datasets<=2.13.0,>=2.8.0->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/80/8a/1dd41557883b6196f8f092011a5c1f72d4d44cf36d7b67d4a5efe3127949/xxhash-3.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (194 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 194.1/194.1 kB 743.6 kB/s eta 0:00:00 Collecting multiprocess (from datasets<=2.13.0,>=2.8.0->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/bc/f7/7ec7fddc92e50714ea3745631f79bd9c96424cb2702632521028e57d3a36/multiprocess-0.70.16-py310-none-any.whl (134 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 134.8/134.8 kB 552.0 kB/s eta 0:00:00 Collecting fsspec>=2021.11.1 (from fsspec[http]>=2021.11.1->datasets<=2.13.0,>=2.8.0->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ad/30/2281c062222dc39328843bd1ddd30ff3005ef8e30b2fd09c4d2792766061/fsspec-2024.2.0-py3-none-any.whl (170 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 170.9/170.9 kB 744.5 kB/s eta 0:00:00 Collecting aiohttp (from datasets<=2.13.0,>=2.8.0->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/93/40/d3decda219ebd5410eba627601d537ec3782efbcadba308e9ce381cc0b71/aiohttp-3.9.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 1.3 MB/s eta 0:00:00 Collecting huggingface-hub<1.0.0,>=0.11.0 (from datasets<=2.13.0,>=2.8.0->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/28/03/7d3c7153113ec59cfb31e3b8ee773f5f420a0dd7d26d40442542b96675c3/huggingface_hub-0.20.3-py3-none-any.whl (330 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 330.1/330.1 kB 1.1 MB/s eta 0:00:00 Collecting packaging (from datasets<=2.13.0,>=2.8.0->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ec/1a/610693ac4ee14fcdf2d9bf3c493370e4f2ef7ae2e19217d7a237ff42367d/packaging-23.2-py3-none-any.whl (53 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 53.0/53.0 kB 616.8 kB/s eta 0:00:00 Collecting six>=1.5 (from python-dateutil>=2.1->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl (11 kB) Requirement already satisfied: charset-normalizer<4,>=2 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from requests>=2.25->modelscope==1.9.5) (2.0.4) Requirement already satisfied: idna<4,>=2.5 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from requests>=2.25->modelscope==1.9.5) (3.4) Requirement already satisfied: certifi>=2017.4.17 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from requests>=2.25->modelscope==1.9.5) (2023.11.17) Collecting crcmod>=1.7 (from oss2->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6b/b0/e595ce2a2527e169c3bcd6c33d2473c1918e0b7f6826a043ca1245dd4e5b/crcmod-1.7.tar.gz (89 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 89.7/89.7 kB 213.4 kB/s eta 0:00:00 Preparing metadata (setup.py) ... done Collecting pycryptodome>=3.4.7 (from oss2->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/af/20/5f29ec45462360e7f61e8688af9fe4a0afae057edfabdada662e11bf97e7/pycryptodome-3.20.0-cp35-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 2.5 MB/s eta 0:00:00 Collecting aliyun-python-sdk-kms>=2.4.1 (from oss2->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3d/ea/d88e08bfc4a0aee0111f1f24c98b19107bc6783441e7e944907c77b2243d/aliyun_python_sdk_kms-2.16.2-py2.py3-none-any.whl (94 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 94.0/94.0 kB 1.1 MB/s eta 0:00:00 Collecting aliyun-python-sdk-core>=2.13.12 (from oss2->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1e/e3/8623c0305022610466ded2b0010a7221e9585046116263dd27cb2e56df36/aliyun-python-sdk-core-2.14.0.tar.gz (443 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 443.0/443.0 kB 3.1 MB/s eta 0:00:00 Preparing metadata (setup.py) ... done Collecting pytz>=2020.1 (from pandas->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9c/3d/a121f284241f08268b21359bd425f7d4825cffc5ac5cd0e1b3d82ffd2b10/pytz-2024.1-py2.py3-none-any.whl (505 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 505.5/505.5 kB 2.2 MB/s eta 0:00:00 Collecting tzdata>=2022.7 (from pandas->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/65/58/f9c9e6be752e9fcb8b6a0ee9fb87e6e7a1f6bcab2cdc73f02bb7ba91ada0/tzdata-2024.1-py2.py3-none-any.whl (345 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 345.4/345.4 kB 2.6 MB/s eta 0:00:00 Collecting importlib-metadata>=6.6.0 (from yapf->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c0/8b/d8427f023c081a8303e6ac7209c16e6878f2765d5b59667f3903fbcfd365/importlib_metadata-7.0.1-py3-none-any.whl (23 kB) Collecting platformdirs>=3.5.1 (from yapf->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/55/72/4898c44ee9ea6f43396fbc23d9bfaf3d06e01b83698bdf2e4c919deceb7c/platformdirs-4.2.0-py3-none-any.whl (17 kB) Collecting tomli>=2.0.1 (from yapf->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9/tomli-2.0.1-py3-none-any.whl (12 kB) Collecting jmespath<1.0.0,>=0.9.3 (from aliyun-python-sdk-core>=2.13.12->oss2->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/07/cb/5f001272b6faeb23c1c9e0acc04d48eaaf5c862c17709d20e3469c6e0139/jmespath-0.10.0-py2.py3-none-any.whl (24 kB) Requirement already satisfied: cryptography>=2.6.0 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from aliyun-python-sdk-core>=2.13.12->oss2->modelscope==1.9.5) (41.0.3) Collecting aiosignal>=1.1.2 (from aiohttp->datasets<=2.13.0,>=2.8.0->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/76/ac/a7305707cb852b7e16ff80eaf5692309bde30e2b1100a1fcacdc8f731d97/aiosignal-1.3.1-py3-none-any.whl (7.6 kB) Collecting frozenlist>=1.1.1 (from aiohttp->datasets<=2.13.0,>=2.8.0->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ec/25/0c87df2e53c0c5d90f7517ca0ff7aca78d050a8ec4d32c4278e8c0e52e51/frozenlist-1.4.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (239 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 239.5/239.5 kB 302.6 kB/s eta 0:00:00 Collecting multidict<7.0,>=4.5 (from aiohttp->datasets<=2.13.0,>=2.8.0->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/33/62/2c9085e571318d51212a6914566fe41dd0e33d7f268f7e2f23dcd3f06c56/multidict-6.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (124 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 124.3/124.3 kB 848.2 kB/s eta 0:00:00 Collecting yarl<2.0,>=1.0 (from aiohttp->datasets<=2.13.0,>=2.8.0->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c3/a0/0ade1409d184cbc9e85acd403a386a7c0563b92ff0f26d138ff9e86e48b4/yarl-1.9.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (301 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 301.6/301.6 kB 826.0 kB/s eta 0:00:00 Collecting async-timeout<5.0,>=4.0 (from aiohttp->datasets<=2.13.0,>=2.8.0->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a7/fa/e01228c2938de91d47b307831c62ab9e4001e747789d0b05baf779a6488c/async_timeout-4.0.3-py3-none-any.whl (5.7 kB) Requirement already satisfied: typing-extensions>=3.7.4.3 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from huggingface-hub<1.0.0,>=0.11.0->datasets<=2.13.0,>=2.8.0->modelscope==1.9.5) (4.7.1) Collecting zipp>=0.5 (from importlib-metadata>=6.6.0->yapf->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d9/66/48866fc6b158c81cc2bfecc04c480f105c6040e8b077bc54c634b4a67926/zipp-3.17.0-py3-none-any.whl (7.4 kB) INFO: pip is looking at multiple versions of multiprocess to determine which version is compatible with other requirements. This could take a while. Collecting multiprocess (from datasets<=2.13.0,>=2.8.0->modelscope==1.9.5) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/35/a8/36d8d7b3e46b377800d8dec47891cdf05842d1a2366909ae4a0c89fbc5e6/multiprocess-0.70.15-py310-none-any.whl (134 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 134.8/134.8 kB 293.1 kB/s eta 0:00:00 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b8/0c/c26b346b41bb1f81ac921fa10074a9595c22e5f99cc89c0410fc4efd5df3/multiprocess-0.70.14-py310-none-any.whl (134 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 134.3/134.3 kB 1.0 MB/s eta 0:00:00 Requirement already satisfied: cffi>=1.12 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from cryptography>=2.6.0->aliyun-python-sdk-core>=2.13.12->oss2->modelscope==1.9.5) (1.16.0) Requirement already satisfied: pycparser in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from cffi>=1.12->cryptography>=2.6.0->aliyun-python-sdk-core>=2.13.12->oss2->modelscope==1.9.5) (2.21) Building wheels for collected packages: oss2, aliyun-python-sdk-core, crcmod Building wheel for oss2 (setup.py) ... done Created wheel for oss2: filename=oss2-2.18.4-py3-none-any.whl size=115939 sha256=b4982e513a03f639608305229f2b722293b6d9c53f1c6bb93c94fb1387f55a99 Stored in directory: /root/.cache/pip/wheels/29/5a/f0/41e21c49b5f9e6623f3da79959757c3815e14cfde87d1f4d3f Building wheel for aliyun-python-sdk-core (setup.py) ... done Created wheel for aliyun-python-sdk-core: filename=aliyun_python_sdk_core-2.14.0-py3-none-any.whl size=535290 sha256=58da75f8b5251fcbf78544e98b8823afb216a481970f53be7c91bd91740d0ba9 Stored in directory: /root/.cache/pip/wheels/5d/a2/13/75ca6264763fad6d7615dcbc0bb71c62059357be6a20147e8e Building wheel for crcmod (setup.py) ... done Created wheel for crcmod: filename=crcmod-1.7-cp310-cp310-linux_x86_64.whl size=23536 sha256=ca6c4ba47d632fac7285ca0fd7a18fdd05b57924f9b3c8dc5a0e217a65f4b7c9 Stored in directory: /root/.cache/pip/wheels/78/30/21/160bc71114a7959e68ea098676241291515e71377d8db6ceea Successfully built oss2 aliyun-python-sdk-core crcmod Installing collected packages: sortedcontainers, pytz, crcmod, addict, zipp, xxhash, tzdata, tqdm, tomli, six, simplejson, scipy, pyyaml, pycryptodome, pyarrow, platformdirs, packaging, multidict, jmespath, gast, fsspec, frozenlist, einops, dill, attrs, async-timeout, yarl, python-dateutil, multiprocess, importlib-metadata, huggingface-hub, aiosignal, yapf, pandas, aliyun-python-sdk-core, aiohttp, aliyun-python-sdk-kms, oss2, datasets, modelscope Successfully installed addict-2.4.0 aiohttp-3.9.3 aiosignal-1.3.1 aliyun-python-sdk-core-2.14.0 aliyun-python-sdk-kms-2.16.2 async-timeout-4.0.3 attrs-23.2.0 crcmod-1.7 datasets-2.13.0 dill-0.3.6 einops-0.7.0 frozenlist-1.4.1 fsspec-2024.2.0 gast-0.5.4 huggingface-hub-0.20.3 importlib-metadata-7.0.1 jmespath-0.10.0 modelscope-1.9.5 multidict-6.0.5 multiprocess-0.70.14 oss2-2.18.4 packaging-23.2 pandas-2.2.0 platformdirs-4.2.0 pyarrow-15.0.0 pycryptodome-3.20.0 python-dateutil-2.8.2 pytz-2024.1 pyyaml-6.0.1 scipy-1.12.0 simplejson-3.19.2 six-1.16.0 sortedcontainers-2.4.0 tomli-2.0.1 tqdm-4.66.2 tzdata-2024.1 xxhash-3.4.1 yapf-0.40.2 yarl-1.9.4 zipp-3.17.0 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv (internlm-demo) root@intern-studio-069640:~# pip install transformers==4.35.2 Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting transformers==4.35.2 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/12/dd/f17b11a93a9ca27728e12512d167eb1281c151c4c6881d3ab59eb58f4127/transformers-4.35.2-py3-none-any.whl (7.9 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.9/7.9 MB 21.9 MB/s eta 0:00:00 Requirement already satisfied: filelock in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from transformers==4.35.2) (3.13.1) Requirement already satisfied: huggingface-hub<1.0,>=0.16.4 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from transformers==4.35.2) (0.20.3) Requirement already satisfied: numpy>=1.17 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from transformers==4.35.2) (1.26.2) Requirement already satisfied: packaging>=20.0 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from transformers==4.35.2) (23.2) Requirement already satisfied: pyyaml>=5.1 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from transformers==4.35.2) (6.0.1) Collecting regex!=2019.12.17 (from transformers==4.35.2) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/81/8a/96a62ce98e8ff1b16db56fde3debc8a571f6b7ea42ee137eb0d995cdfa26/regex-2023.12.25-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (773 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 774.0/774.0 kB 36.1 MB/s eta 0:00:00 Requirement already satisfied: requests in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from transformers==4.35.2) (2.31.0) Collecting tokenizers<0.19,>=0.14 (from transformers==4.35.2) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1c/5d/cf5e122ce4f1a29f165b2a69dc33d1ff30bce303343d58a54775ddba5d51/tokenizers-0.15.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.6/3.6 MB 87.8 MB/s eta 0:00:00 Collecting safetensors>=0.3.1 (from transformers==4.35.2) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d0/ba/b2254fafc7f5fdc98a2fa4d5a5eeb029fbf9589ec87f2c230c3ac0a1dd53/safetensors-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.3/1.3 MB 29.7 MB/s eta 0:00:00 Requirement already satisfied: tqdm>=4.27 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from transformers==4.35.2) (4.66.2) Requirement already satisfied: fsspec>=2023.5.0 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from huggingface-hub<1.0,>=0.16.4->transformers==4.35.2) (2024.2.0) Requirement already satisfied: typing-extensions>=3.7.4.3 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from huggingface-hub<1.0,>=0.16.4->transformers==4.35.2) (4.7.1) Requirement already satisfied: charset-normalizer<4,>=2 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from requests->transformers==4.35.2) (2.0.4) Requirement already satisfied: idna<4,>=2.5 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from requests->transformers==4.35.2) (3.4) Requirement already satisfied: urllib3<3,>=1.21.1 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from requests->transformers==4.35.2) (1.26.18) Requirement already satisfied: certifi>=2017.4.17 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from requests->transformers==4.35.2) (2023.11.17) Installing collected packages: safetensors, regex, tokenizers, transformers Successfully installed regex-2023.12.25 safetensors-0.4.2 tokenizers-0.15.2 transformers-4.35.2 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv (internlm-demo) root@intern-studio-069640:~# pip install streamlit==1.24.0 Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting streamlit==1.24.0 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3d/5f/1716c66c58a8b080f9673e7ca569044b1b8ac6a5cd8519fe4b1afa89abf8/streamlit-1.24.0-py2.py3-none-any.whl (8.9 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.9/8.9 MB 18.4 MB/s eta 0:00:00 Collecting altair<6,>=4.0 (from streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c5/e4/7fcceef127badbb0d644d730d992410e4f3799b295c9964a172f92a469c7/altair-5.2.0-py3-none-any.whl (996 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 996.9/996.9 kB 29.2 MB/s eta 0:00:00 Collecting blinker<2,>=1.0.0 (from streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fa/2a/7f3714cbc6356a0efec525ce7a0613d581072ed6eb53eb7b9754f33db807/blinker-1.7.0-py3-none-any.whl (13 kB) Collecting cachetools<6,>=4.0 (from streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a2/91/2d843adb9fbd911e0da45fbf6f18ca89d07a087c3daa23e955584f90ebf4/cachetools-5.3.2-py3-none-any.whl (9.3 kB) Collecting click<9,>=7.0 (from streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/00/2e/d53fa4befbf2cfa713304affc7ca780ce4fc1fd8710527771b58311a3229/click-8.1.7-py3-none-any.whl (97 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.9/97.9 kB 8.0 MB/s eta 0:00:00 Collecting importlib-metadata<7,>=1.4 (from streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/59/9b/ecce94952ab5ea74c31dcf9ccf78ccd484eebebef06019bf8cb579ab4519/importlib_metadata-6.11.0-py3-none-any.whl (23 kB) Requirement already satisfied: numpy<2,>=1 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from streamlit==1.24.0) (1.26.2) Requirement already satisfied: packaging<24,>=14.1 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from streamlit==1.24.0) (23.2) Requirement already satisfied: pandas<3,>=0.25 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from streamlit==1.24.0) (2.2.0) Collecting pillow<10,>=6.2.0 (from streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/25/6b/d3c35d207c9c0b6c2f855420f62e64ef43d348e8c797ad1c32b9f2106a19/Pillow-9.5.0-cp310-cp310-manylinux_2_28_x86_64.whl (3.4 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.4/3.4 MB 64.3 MB/s eta 0:00:00 Collecting protobuf<5,>=3.20 (from streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/81/9e/63501b8d5b4e40c7260049836bd15ec3270c936e83bc57b85e4603cc212c/protobuf-4.25.2-cp37-abi3-manylinux2014_x86_64.whl (294 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 294.6/294.6 kB 7.7 MB/s eta 0:00:00 Requirement already satisfied: pyarrow>=4.0 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from streamlit==1.24.0) (15.0.0) Collecting pympler<2,>=0.9 (from streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2c/42/41e1469ed0b37b9c8532cb8074bea179f7d85ee7e82a59b5b6c289ed6045/Pympler-1.0.1-py3-none-any.whl (164 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 164.8/164.8 kB 19.6 MB/s eta 0:00:00 Requirement already satisfied: python-dateutil<3,>=2 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from streamlit==1.24.0) (2.8.2) Requirement already satisfied: requests<3,>=2.4 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from streamlit==1.24.0) (2.31.0) Collecting rich<14,>=10.11.0 (from streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/be/be/1520178fa01eabe014b16e72a952b9f900631142ccd03dc36cf93e30c1ce/rich-13.7.0-py3-none-any.whl (240 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 240.6/240.6 kB 26.1 MB/s eta 0:00:00 Collecting tenacity<9,>=8.0.0 (from streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f4/f1/990741d5bb2487d529d20a433210ffa136a367751e454214013b441c4575/tenacity-8.2.3-py3-none-any.whl (24 kB) Collecting toml<2 (from streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/44/6f/7120676b6d73228c96e17f1f794d8ab046fc910d781c8d151120c3f1569e/toml-0.10.2-py2.py3-none-any.whl (16 kB) Requirement already satisfied: typing-extensions<5,>=4.0.1 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from streamlit==1.24.0) (4.7.1) Collecting tzlocal<5,>=1.1 (from streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/55/a6/a75af44665e5e77e52f6789eef4f8bc056c8e039d96c804b975806942580/tzlocal-4.3.1-py3-none-any.whl (20 kB) Collecting validators<1,>=0.2 (from streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3a/0c/785d317eea99c3739821718f118c70537639aa43f96bfa1d83a71f68eaf6/validators-0.22.0-py3-none-any.whl (26 kB) Collecting gitpython!=3.1.19,<4,>=3 (from streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/45/c6/a637a7a11d4619957cb95ca195168759a4502991b1b91c13d3203ffc3748/GitPython-3.1.41-py3-none-any.whl (196 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 196.4/196.4 kB 23.3 MB/s eta 0:00:00 Collecting pydeck<1,>=0.1.dev5 (from streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/10/4b/2fc80540e2d3903452245bb657c7f758ec7342420507d1e4091b0161856e/pydeck-0.8.1b0-py2.py3-none-any.whl (4.8 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.8/4.8 MB 73.2 MB/s eta 0:00:00 Collecting tornado<7,>=6.0.3 (from streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9f/12/11d0a757bb67278d3380d41955ae98527d5ad18330b2edbdc8de222b569b/tornado-6.4-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (435 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 435.4/435.4 kB 37.4 MB/s eta 0:00:00 Collecting watchdog (from streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/91/7b/26d2f43aa9fe428416be21ee1cb9ac75638cf302466b7e706c14eeaea42c/watchdog-4.0.0-py3-none-manylinux2014_x86_64.whl (82 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 83.0/83.0 kB 10.7 MB/s eta 0:00:00 Requirement already satisfied: jinja2 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from altair<6,>=4.0->streamlit==1.24.0) (3.1.2) Collecting jsonschema>=3.0 (from altair<6,>=4.0->streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/39/9d/b035d024c62c85f2e2d4806a59ca7b8520307f34e0932fbc8cc75fe7b2d9/jsonschema-4.21.1-py3-none-any.whl (85 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 85.5/85.5 kB 5.6 MB/s eta 0:00:00 Collecting toolz (from altair<6,>=4.0->streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b7/8a/d82202c9f89eab30f9fc05380daae87d617e2ad11571ab23d7c13a29bb54/toolz-0.12.1-py3-none-any.whl (56 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 56.1/56.1 kB 7.0 MB/s eta 0:00:00 Collecting gitdb<5,>=4.0.1 (from gitpython!=3.1.19,<4,>=3->streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fd/5b/8f0c4a5bb9fd491c277c21eff7ccae71b47d43c4446c9d0c6cff2fe8c2c4/gitdb-4.0.11-py3-none-any.whl (62 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.7/62.7 kB 123.5 kB/s eta 0:00:00 Requirement already satisfied: zipp>=0.5 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from importlib-metadata<7,>=1.4->streamlit==1.24.0) (3.17.0) Requirement already satisfied: pytz>=2020.1 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from pandas<3,>=0.25->streamlit==1.24.0) (2024.1) Requirement already satisfied: tzdata>=2022.7 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from pandas<3,>=0.25->streamlit==1.24.0) (2024.1) Requirement already satisfied: six>=1.5 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from python-dateutil<3,>=2->streamlit==1.24.0) (1.16.0) Requirement already satisfied: charset-normalizer<4,>=2 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from requests<3,>=2.4->streamlit==1.24.0) (2.0.4) Requirement already satisfied: idna<4,>=2.5 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from requests<3,>=2.4->streamlit==1.24.0) (3.4) Requirement already satisfied: urllib3<3,>=1.21.1 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from requests<3,>=2.4->streamlit==1.24.0) (1.26.18) Requirement already satisfied: certifi>=2017.4.17 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from requests<3,>=2.4->streamlit==1.24.0) (2023.11.17) Collecting markdown-it-py>=2.2.0 (from rich<14,>=10.11.0->streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/42/d7/1ec15b46af6af88f19b8e5ffea08fa375d433c998b8a7639e76935c14f1f/markdown_it_py-3.0.0-py3-none-any.whl (87 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 87.5/87.5 kB 264.0 kB/s eta 0:00:00 Collecting pygments<3.0.0,>=2.13.0 (from rich<14,>=10.11.0->streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/97/9c/372fef8377a6e340b1704768d20daaded98bf13282b5327beb2e2fe2c7ef/pygments-2.17.2-py3-none-any.whl (1.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 1.1 MB/s eta 0:00:00 Collecting pytz-deprecation-shim (from tzlocal<5,>=1.1->streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/eb/73/3eaab547ca809754e67e06871cff0fc962bafd4b604e15f31896a0f94431/pytz_deprecation_shim-0.1.0.post0-py2.py3-none-any.whl (15 kB) Collecting smmap<6,>=3.0.1 (from gitdb<5,>=4.0.1->gitpython!=3.1.19,<4,>=3->streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a7/a5/10f97f73544edcdef54409f1d839f6049a0d79df68adbc1ceb24d1aaca42/smmap-5.0.1-py3-none-any.whl (24 kB) Requirement already satisfied: MarkupSafe>=2.0 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from jinja2->altair<6,>=4.0->streamlit==1.24.0) (2.1.1) Requirement already satisfied: attrs>=22.2.0 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit==1.24.0) (23.2.0) Collecting jsonschema-specifications>=2023.03.6 (from jsonschema>=3.0->altair<6,>=4.0->streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ee/07/44bd408781594c4d0a027666ef27fab1e441b109dc3b76b4f836f8fd04fe/jsonschema_specifications-2023.12.1-py3-none-any.whl (18 kB) Collecting referencing>=0.28.4 (from jsonschema>=3.0->altair<6,>=4.0->streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/90/10/1c92edb0a0a14b67ff825bc338e74bc49ab27d3f3bae3f9a02838cba546f/referencing-0.33.0-py3-none-any.whl (26 kB) Collecting rpds-py>=0.7.1 (from jsonschema>=3.0->altair<6,>=4.0->streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/8c/f1/09bee4d70305e79ecad4f3ccee583f0185c06a5f58befdc3544cf8b18536/rpds_py-0.17.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 2.1 MB/s eta 0:00:00 Collecting mdurl~=0.1 (from markdown-it-py>=2.2.0->rich<14,>=10.11.0->streamlit==1.24.0) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl (10.0 kB) Installing collected packages: watchdog, validators, tornado, toolz, toml, tenacity, smmap, rpds-py, pytz-deprecation-shim, pympler, pygments, protobuf, pillow, mdurl, importlib-metadata, click, cachetools, blinker, tzlocal, referencing, pydeck, markdown-it-py, gitdb, rich, jsonschema-specifications, gitpython, jsonschema, altair, streamlit Attempting uninstall: pillow Found existing installation: Pillow 10.0.1 Uninstalling Pillow-10.0.1: Successfully uninstalled Pillow-10.0.1 Attempting uninstall: importlib-metadata Found existing installation: importlib-metadata 7.0.1 Uninstalling importlib-metadata-7.0.1: Successfully uninstalled importlib-metadata-7.0.1 Successfully installed altair-5.2.0 blinker-1.7.0 cachetools-5.3.2 click-8.1.7 gitdb-4.0.11 gitpython-3.1.41 importlib-metadata-6.11.0 jsonschema-4.21.1 jsonschema-specifications-2023.12.1 markdown-it-py-3.0.0 mdurl-0.1.2 pillow-9.5.0 protobuf-4.25.2 pydeck-0.8.1b0 pygments-2.17.2 pympler-1.0.1 pytz-deprecation-shim-0.1.0.post0 referencing-0.33.0 rich-13.7.0 rpds-py-0.17.1 smmap-5.0.1 streamlit-1.24.0 tenacity-8.2.3 toml-0.10.2 toolz-0.12.1 tornado-6.4 tzlocal-4.3.1 validators-0.22.0 watchdog-4.0.0 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv (internlm-demo) root@intern-studio-069640:~# pip install sentencepiece==0.1.99 Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting sentencepiece==0.1.99 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/7f/e5/323dc813b3e1339305f888d035e2f3725084fc4dcf051995b366dd26cc90/sentencepiece-0.1.99-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.3/1.3 MB 3.6 MB/s eta 0:00:00 Installing collected packages: sentencepiece Successfully installed sentencepiece-0.1.99 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv (internlm-demo) root@intern-studio-069640:~# pip install accelerate==0.24.1 Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting accelerate==0.24.1 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/13/9e/ee987874058f2d93006961f6ff49e0bcb60ab9c26709ebe06bfa8707a4d8/accelerate-0.24.1-py3-none-any.whl (261 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 261.4/261.4 kB 1.8 MB/s eta 0:00:00 Requirement already satisfied: numpy>=1.17 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from accelerate==0.24.1) (1.26.2) Requirement already satisfied: packaging>=20.0 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from accelerate==0.24.1) (23.2) Collecting psutil (from accelerate==0.24.1) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c5/4f/0e22aaa246f96d6ac87fe5ebb9c5a693fbe8877f537a1022527c47ca43c5/psutil-5.9.8-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (288 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 288.2/288.2 kB 5.2 MB/s eta 0:00:00 Requirement already satisfied: pyyaml in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from accelerate==0.24.1) (6.0.1) Requirement already satisfied: torch>=1.10.0 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from accelerate==0.24.1) (2.0.1) Requirement already satisfied: huggingface-hub in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from accelerate==0.24.1) (0.20.3) Requirement already satisfied: filelock in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from torch>=1.10.0->accelerate==0.24.1) (3.13.1) Requirement already satisfied: typing-extensions in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from torch>=1.10.0->accelerate==0.24.1) (4.7.1) Requirement already satisfied: sympy in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from torch>=1.10.0->accelerate==0.24.1) (1.11.1) Requirement already satisfied: networkx in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from torch>=1.10.0->accelerate==0.24.1) (3.1) Requirement already satisfied: jinja2 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from torch>=1.10.0->accelerate==0.24.1) (3.1.2) Requirement already satisfied: fsspec>=2023.5.0 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from huggingface-hub->accelerate==0.24.1) (2024.2.0) Requirement already satisfied: requests in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from huggingface-hub->accelerate==0.24.1) (2.31.0) Requirement already satisfied: tqdm>=4.42.1 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from huggingface-hub->accelerate==0.24.1) (4.66.2) Requirement already satisfied: MarkupSafe>=2.0 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from jinja2->torch>=1.10.0->accelerate==0.24.1) (2.1.1) Requirement already satisfied: charset-normalizer<4,>=2 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from requests->huggingface-hub->accelerate==0.24.1) (2.0.4) Requirement already satisfied: idna<4,>=2.5 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from requests->huggingface-hub->accelerate==0.24.1) (3.4) Requirement already satisfied: urllib3<3,>=1.21.1 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from requests->huggingface-hub->accelerate==0.24.1) (1.26.18) Requirement already satisfied: certifi>=2017.4.17 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from requests->huggingface-hub->accelerate==0.24.1) (2023.11.17) Requirement already satisfied: mpmath>=0.19 in ./.conda/envs/internlm-demo/lib/python3.10/site-packages (from sympy->torch>=1.10.0->accelerate==0.24.1) (1.3.0) Installing collected packages: psutil, accelerate Successfully installed accelerate-0.24.1 psutil-5.9.8 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv (internlm-demo) root@intern-studio-069640:~#View Code
2.2 模型下载
share
目录下已经为我们准备了全系列的 InternLM
模型,所以我们可以直接复制即可。使用如下命令复制:
mkdir -p /root/model/Shanghai_AI_Laboratory cp -r /root/share/temp/model_repos/internlm-chat-7b /root/model/Shanghai_AI_Laboratory
屏幕输出:
(internlm-demo) root@intern-studio-069640:~# mkdir -p /root/model/Shanghai_AI_Laboratory (internlm-demo) root@intern-studio-069640:~# cp -r /root/share/temp/model_repos/internlm-chat-7b /root/model/Shanghai_AI_LaboratoryView Code
2.3 代码准备
首先 clone
代码,在 /root
路径下新建 code
目录,然后切换路径, clone 代码.
mkdir code
cd /root/code git clone https://gitee.com/internlm/InternLM.git
屏幕输出:
(internlm-demo) root@intern-studio-069640:~# mkdir code (internlm-demo) root@intern-studio-069640:~# cd /root/code (internlm-demo) root@intern-studio-069640:~/code# git clone https://gitee.com/internlm/InternLM.git Cloning into 'InternLM'... remote: Enumerating objects: 2604, done. remote: Counting objects: 100% (592/592), done. remote: Compressing objects: 100% (264/264), done. remote: Total 2604 (delta 323), reused 581 (delta 318), pack-reused 2012 Receiving objects: 100% (2604/2604), 4.87 MiB | 1.08 MiB/s, done. Resolving deltas: 100% (1607/1607), done. (internlm-demo) root@intern-studio-069640:~/code#View Code
切换 commit 版本,与教程 commit 版本保持一致:
cd InternLM git checkout 3028f07cb79e5b1d7342f4ad8d11efad3fd13d17
屏幕输出:
(internlm-demo) root@intern-studio-069640:~/code# cd InternLM (internlm-demo) root@intern-studio-069640:~/code/InternLM# git checkout 3028f07cb79e5b1d7342f4ad8d11efad3fd13d17 Note: switching to '3028f07cb79e5b1d7342f4ad8d11efad3fd13d17'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by switching back to a branch. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -c with the switch command. Example: git switch -c <new-branch-name> Or undo this operation with: git switch - Turn off this advice by setting config variable advice.detachedHead to false HEAD is now at 3028f07 fix(readme): update README with original weight download link (#460) (internlm-demo) root@intern-studio-069640:~/code/InternLM#View Code
将 /root/code/InternLM/web_demo.py
中 29 行和 33 行的模型更换为本地的 /root/model/Shanghai_AI_Laboratory/internlm-chat-7b
。
2.4 终端运行
在 /root/code/InternLM
目录下新建一个 cli_demo.py
文件,将以下代码填入其中:
import torch from transformers import AutoTokenizer, AutoModelForCausalLM model_name_or_path = "/root/model/Shanghai_AI_Laboratory/internlm-chat-7b" tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained(model_name_or_path, trust_remote_code=True, torch_dtype=torch.bfloat16, device_map='auto') model = model.eval() system_prompt = """You are an AI assistant whose name is InternLM (书生·浦语). - InternLM (书生·浦语) is a conversational language model that is developed by Shanghai AI Laboratory (上海人工智能实验室). It is designed to be helpful, honest, and harmless. - InternLM (书生·浦语) can understand and communicate fluently in the language chosen by the user such as English and 中文. """ messages = [(system_prompt, '')] print("=============Welcome to InternLM chatbot, type 'exit' to exit.=============") while True: input_text = input("User >>> ") input_text = input_text.replace(' ', '') if input_text == "exit": break response, history = model.chat(tokenizer, input_text, history=messages) messages.append((input_text, response)) print(f"robot >>> {response}")
然后在终端运行以下命令开始体验:
python /root/code/InternLM/cli_demo.py
屏幕输出:
(internlm-demo) root@intern-studio-069640:~/code/InternLM# vim cli_demo.py (internlm-demo) root@intern-studio-069640:~/code/InternLM# python /root/code/InternLM/cli_demo.py Loading checkpoint shards: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:42<00:00, 5.36s/it] =============Welcome to InternLM chatbot, type 'exit' to exit.============= User >>> robot >>> 您好!我能帮助您处理任何问题。请问您有什么需要我帮忙的? User >>> robot >>> 您好!请问您需要了解什么方面的知识呢?我将尽我所能为您提供帮助。View Code
2.5 web demo 运行
截屏: