书生·浦语大模型实战营课程——作业4

一. 训练自我认知个人小助手

1. 前期配置

1.1 环境创建

首先在平台上选择10% A100 * 1cuda11.7-conda镜像,然后输入

studio-conda xtuner0.1.17

创建环境,接着输入

git clone -b v0.1.17 https://github.com/InternLM/xtuner

拉取xtuner源代码。

1.2 数据集创建

可以创建一个文件夹存放所需数据

mkdir -p /root/ft && cd /root/ft
mkdir -p /root/ft/data && cd /root/ft/data

在data文件夹中创建python文件,用于生成数据集,文件中输入下列内容

name可以改成自己所需要的内容,然后运行该py文件创建数据集。

1.3 模型选择

在本次作业中选择InterLM2-Chat-1.8B作为基础模型,输入

ln -s /root/share/new_models/Shanghai_AI_Laboratory/internlm2-chat-1_8b /root/ft/model

创建软链接,便于节省空间。

1.4 拷贝config文件

mkdir -p /root/ft/config
xtuner copy-cfg internlm2_1_8b_qlora_alpaca_e3 /root/ft/config

2. 训练模型

相应修改好config文件后,输入

xtuner train /root/ft/config/internlm2_1_8b_qlora_alpaca_e3_copy.py --work-dir /root/ft/train

开始训练模型,可以看到第300轮训练后的测试效果

但在第600轮的时候出现过拟合现象

3. 模型转换

3.1 模型转换

创建一个文件夹以保存转换后的模型

mkdir -p /root/ft/huggingface

然后输入

xtuner convert pth_to_hf /root/ft/train/internlm2_1_8b_qlora_alpaca_e3_copy.py /root/ft/train/iter_300.pth /root/ft/huggingface

转换模型

3.2 模型整合

输入

xtuner convert merge /root/ft/model /root/ft/huggingface /root/ft/final_model

整合模型

3.3 对话测试

最后可以输入

xtuner chat /root/ft/model --adapter /root/ft/huggingface --prompt-template internlm2_chat

使用Adapter + 基座模型的方式进行对话测试,可以看出依旧出现了过拟合现象

二. 进阶作业

(待续)

  • 10
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值