初始化项目,由ModelHub XC社区提供模型
Model: yokebtc/advertise Source: Original Platform
This commit is contained in:
96
README.md
Normal file
96
README.md
Normal file
@@ -0,0 +1,96 @@
|
||||
---
|
||||
frameworks:
|
||||
- Tensorflow
|
||||
license: Apache License 2.0
|
||||
tasks:
|
||||
- text-generation
|
||||
---
|
||||
###### 该模型当前使用的是默认介绍模版,处于“预发布”阶段,页面仅限所有者可见。
|
||||
###### 请根据[模型贡献文档说明](https://www.modelscope.cn/docs/%E5%A6%82%E4%BD%95%E6%92%B0%E5%86%99%E5%A5%BD%E7%94%A8%E7%9A%84%E6%A8%A1%E5%9E%8B%E5%8D%A1%E7%89%87),及时完善模型卡片内容。ModelScope平台将在模型卡片完善后展示。谢谢您的理解。
|
||||
#### Clone with HTTP
|
||||
```bash
|
||||
git clone https://www.modelscope.cn/yokebtc/advertise.git
|
||||
```
|
||||
|
||||
 | [demo.png](http://minio.datapandora.cn/chatgpt/screencapture-127-0-0-1-6006-2024-01-31-15_37_23y.png)
|
||||
|
||||
### 4.2 微调步骤
|
||||
|
||||
#### 4.2.1 准备工作
|
||||
> xtuner 是从国内的 ModelScope 平台下载 MS-Agent 数据集,因此不用提前手动下载数据集文件。
|
||||
|
||||
```bash
|
||||
# 准备工作
|
||||
mkdir ~/ft-msagent && cd ~/ft-msagent
|
||||
cp -r ~/ft-oasst1/internlm-chat-7b .
|
||||
|
||||
# 查看配置文件
|
||||
xtuner list-cfg | grep msagent
|
||||
|
||||
# 复制配置文件到当前目录
|
||||
xtuner copy-cfg internlm_7b_qlora_msagent_react_e3_gpu8 .
|
||||
|
||||
# 修改配置文件中的模型为本地路径
|
||||
vim ./internlm_7b_qlora_msagent_react_e3_gpu8_copy.py
|
||||
```
|
||||
|
||||
```diff
|
||||
- pretrained_model_name_or_path = 'internlm/internlm-chat-7b'
|
||||
+ pretrained_model_name_or_path = './internlm-chat-7b'
|
||||
```
|
||||
|
||||
#### 4.2.2 开始微调
|
||||
```Bash
|
||||
xtuner train ./internlm_7b_qlora_msagent_react_e3_gpu8_copy.py --deepspeed deepspeed_zero2
|
||||
```
|
||||
|
||||
### 4.3 直接使用
|
||||
|
||||
> 由于 msagent 的训练非常费时,大家如果想尽快把这个教程跟完,可以直接从 modelScope 拉取咱们已经微调好了的 Adapter。如下演示。
|
||||
|
||||
#### 4.3.1 下载 Adapter
|
||||
```Bash
|
||||
cd ~/ft-msagent
|
||||
apt install git git-lfs
|
||||
git lfs install
|
||||
git lfs clone https://www.modelscope.cn/xtuner/internlm-7b-qlora-msagent-react.git
|
||||
```
|
||||
|
||||
OK,现在目录应该长这样:
|
||||
- internlm_7b_qlora_msagent_react_e3_gpu8_copy.py
|
||||
- internlm-7b-qlora-msagent-react
|
||||
- internlm-chat-7b
|
||||
- work_dir(可有可无)
|
||||
|
||||
有了这个在 msagent 上训练得到的Adapter,模型现在已经有 agent 能力了!就可以加 --lagent 以调用来自 lagent 的代理功能了!
|
||||
|
||||
#### 4.3.2 添加 serper 环境变量
|
||||
|
||||
> **开始 chat 之前,还要加个 serper 的环境变量:**
|
||||
>
|
||||
> 去 serper.dev 免费注册一个账号,生成自己的 api key。这个东西是用来给 lagent 去获取 google 搜索的结果的。等于是 serper.dev 帮你去访问 google,而不是从你自己本地去访问 google 了。
|
||||
|
||||

|
||||
|
||||
添加 serper api key 到环境变量:
|
||||
|
||||
```bash
|
||||
export SERPER_API_KEY=abcdefg
|
||||
```
|
||||
|
||||
#### 4.3.3 xtuner + agent,启动!
|
||||
|
||||
```bash
|
||||
xtuner chat ./internlm-chat-7b --adapter internlm-7b-qlora-msagent-react --lagent
|
||||
```
|
||||
|
||||
|
||||
#### 4.3.4 报错处理
|
||||
|
||||
xtuner chat 增加 --lagent 参数后,报错 ```TypeError: transfomers.modelsauto.auto factory. BaseAutoModelClass.from pretrained() got multiple values for keyword argument "trust remote code"```
|
||||
|
||||
注释掉已安装包中的代码:
|
||||
|
||||
```bash
|
||||
vim /root/xtuner019/xtuner/xtuner/tools/chat.py
|
||||
```
|
||||
Reference in New Issue
Block a user