上海浦语大模型

一、第一课

二、第二课

1.1、环境准备

bash # 请每次使用 jupyter lab 打开终端时务必先执行 bash 命令进入 bash 中
bash /root/share/install_conda_env_internlm_base.sh internlm-demo  # 执行该脚本文件来安装项目实验环境

然后使用以下命令激活环境

conda activate internlm-demo

并在环境中安装运行 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

1.2模型下载

方式一

InternStudio平台的 share 目录下已经为我们准备了全系列的 InternLM 模型,所以我们可以直接复制即可。使用如下命令复制:

mkdir -p /root/model/Shanghai_AI_Laboratory
cp -r /root/share/temp/model_repos/internlm-chat-7b /root/model/Shanghai_AI_Laboratory

1.3准备代码

首先 clone 代码,在 /root 路径下新建 code 目录,然后切换路径, clone 代码:

cd /root/code
git clone https://gitee.com/internlm/InternLM.git

切换 commit 版本,与教程 commit 版本保持一致,可以让大家更好的复现:

cd InternLM
git checkout 3028f07cb79e5b1d7342f4ad8d11efad3fd13d17

将 /root/code/InternLM/web_demo.py中 29 行和 33 行的模型更换为本地的 /root/model/Shanghai_AI_Laboratory/internlm-chat-7b。

1.4终端运行

我们可以在 /root/code/InternLM 目录下新建一个 cli_demo.py 文件,将以下代码填入其中:

见cli_demo.py文件

然后在终端运行以下命令,即可体验 InternLM-Chat-7B 模型的对话能力。对话效果如下所示:

python /root/code/InternLM/cli_demo.py

1.5web端应用

注意:需要暂停前面对话,资源有限

我们切换到 VScode 中,运行 /root/code/InternLM 目录下的 web_demo.py 文件,输入以下命令后,查看本教程5.2配置本地端口后,将端口映射到本地。在本地浏览器输入 http://127.0.0.1:6006 即可。

bash
conda activate internlm-demo  # 首次进入 vscode 会默认是 base 环境,所以首先切换环境
cd /root/code/InternLM
streamlit run web_demo.py --server.address 127.0.0.1 --server.port 6006

要在浏览器打开http://127.0.0.1:6006页面后,模型才会加载,如下图所示:

1.6Lagent 智能体工具调用 Demo

1 环境准备

2 模型下载

3 Lagent 安装

首先切换路径到 /root/code 克隆 lagent 仓库,并通过 pip install -e . 源码安装 Lagent

cd /root/code
git clone https://gitee.com/internlm/lagent.git
cd /root/code/lagent
git checkout 511b03889010c4811b1701abb153e02b8e94fb5e # 尽量保证和教程commit版本一致
pip install -e . # 源码安装

4修改代码

由于代码修改的地方比较多,大家直接将 /root/code/lagent/examples/react_web_demo.py 内容替换为以下代码

详细见教程

5Demo 运行

streamlit run /root/code/lagent/examples/react_web_demo.py --server.address 127.0.0.1 --server.port 6006

用同样的方法我们依然切换到 VScode 页面,运行成功后,查看本教程5.2配置本地端口后,将端口映射到本地。在本地浏览器输入 http://127.0.0.1:6006 即可。

我们在 Web 页面选择 InternLM 模型,等待模型加载完毕后,输入数学问题 已知 2x+3=13,求x ,此时 InternLM-Chat-7B 模型理解题意生成解此题的 Python 代码,Lagent 调度送入 Python 代码解释器求出该问题的解。

1.7浦语·灵笔图文理解创作 Demo

1 环境准备

2 模型下载

pip install lit cmake

pip install transformers==4.33.1 timm==0.4.12 sentencepiece==0.1.99 gradio==3.44.4 markdown2==2.4.10 xlsxwriter==3.1.2 einops accelerate

3代码准备

在 /root/code git clone InternLM-XComposer 仓库的代码

cd /root/code git clone <https://gitee.com/internlm/InternLM-XComposer.git> cd /root/code/InternLM-XComposer git checkout 3e8c79051a1356b9c388a6447867355c0634932d # 最好保证和教程的 commit 版本一致

4终端运行

二、基于 InternLM 和 LangChain 搭建你的知识库

三、XTuner 大模型单卡低成本微调实战 

四、LMDeploy 的量化和部署

五、OpenCompass 评测

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值