玩转InternLM2-Chat-1.8B 模型进行智能对话

1.环境配置

conda create -n demo python==3.10 -y
conda activate demo
conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.7 -c pytorch -c nvidia

2.激活环境

conda activate demo

3.环境包安装

pip install huggingface-hub==0.17.3
pip install transformers==4.34 
pip install psutil==5.9.8
pip install accelerate==0.24.1
pip install streamlit==1.32.2 
pip install matplotlib==3.8.3 
pip install modelscope==1.9.5
pip install sentencepiece==0.1.99

4.下载 InternLM2-Chat-1.8B 模型

python /root/demo/download_mini.py

5.加载模型

python /root/demo/cli_demo.py

6.chat创作小故事

进阶作业

1.使用 Lagent 运行 InternLM2-Chat-7B 模型

   Lagent 相关知识:

   Lagent 是一个轻量级、开源的基于大语言模型的智能体(agent)框架,支持用户快速地将一个大语言模型转变为多种类型的智能体,并提供了一些典型工具为大语言模型赋能。流式输出,接口统一。

配置基础环境

打开文件路径:cd /root/demo
git 命令下载 Lagent 相关的代码并安装代码库:git clone https://gitee.com/internlm/lagent.git
cd /root/demo/lagent
git checkout 581d9fb8987a5d9b72bb9ebd37a95efd47d479ac
pip install -e . 

Lagent 运行 InternLM2-Chat-7B 模型为内核的智能体

使用7b模型:InternLM2-Chat-7b

打开lagent路径:cd /root/demo/lagent

构造模型软连接:ln -s /root/share/new_models/Shanghai_AI_Laboratory/internlm2-chat-7b /root/models/internlm2-chat-7b

修改lagent/examples/internlm2_agent_web_demo_hf.py文件71行为7b模型:

value='/root/models/internlm2-chat-7b'

输入以下命令运行加载模型:

streamlit run /root/demo/lagent/examples/internlm2_agent_web_demo_hf.py --server.address 127.0.0.1 --server.port 6006

本地端口环境配置本地 PowerShell,在ssh链接中查看端口号,修改自己的端口号

ssh -CNg -L 6006:127.0.0.1:6006 root@ssh.intern-ai.org.cn -p 自己的端口号

PowerShell环境输入链接密码,密码在ssh连接中复制。

浏览器访问 http://127.0.0.1:6006

提示词栏中输入:请解方程 2*X=1360 之中 X 的结果。求x,7b模型返回如下:

提示词栏中输入:快速傅里叶推导,7b模型返回如下:

  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值