浦语书生大模型实战训练营02笔记

发布时间 2024-01-10 23:32:35作者: 编程随行

1.打开算力平台,选择合适的配置进入算力开发机进入jupyter工具终端安装开发所需python深度学习环境:

 bash # 请每次使用 jupyter lab 打开终端时务必先执行 bash 命令进入 bash 中
 bash /root/share/install_conda_env_internlm_base.sh internlm-demo # 执行该脚本文件来安装项目实验环境
 激活环境:conda activate internlm-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

2.下载模型:最快的方式是复制算力机上共享模型

 mkdir -p /root/model/Shanghai_AI_Laboratory
 cp -r /root/share/temp/model_repos/internlm-chat-7b /root/model/Shanghai_AI_Laboratory
 拉取代码,与教程git保持一致:cd InternLM
  git checkout 3028f07cb79e5b1d7342f4ad8d11efad3fd13d17
 更换本地模型:
  将 /root/code/InternLM/web_demo.py 中 29 行和 33 行的模型更换为本地的 /root/model/Shanghai_AI_Laboratory/internlm-chat-7b。/root/model/Shanghai_AI_Laboratory/internlm-chat-7b
  1. 创建模型运行代码 python cli_demo.py

4.运行:效果如下:

基础 作业: