InternVL 部署微调实践
我们选定的任务是让InternVL-2B生成文生图提示词,这个任务需要VLM对图片有格式化的描述并输出。
让我们来一起完成一个用VLM模型进行冷笑话生成,让你的模型说出很逗的冷笑话吧。在这里,我们微调InterenVL使用xtuner。部署InternVL使用lmdeploy。
模型下载
本项目中主要下载的是1~8B的模型
多模态大语言模型 (InternVL 2.0)
| Model Name | Vision Part | Language Part | HF Link | MS Link | Document |
|---|---|---|---|---|---|
| InternVL2‑1B | InternViT‑300M‑448px | Qwen2‑0.5B‑Instruct | 🤗 link | 🤖 link | 📖 doc |
| InternVL2‑2B | InternViT‑300M‑448px | internlm2‑chat‑1‑8b | 🤗 link | 🤖 link | 📖 doc |
| InternVL2‑4B | InternViT‑300M‑448px | Phi‑3‑mini‑128k‑instruct | 🤗 link | 🤖 link | 📖 doc |
| InternVL2‑8B | InternViT‑300M‑448px | internlm2_5‑7b‑chat | 🤗 link | 🤖 link | 📖 doc |
准备环境
这里我们来手动配置下xtuner。
配置虚拟环境
conda create --name xtuner python=3.10 -y
# 激活虚拟环境(注意:后续的所有操作都需要在这个虚拟环境中进行)
conda activate xtuner
# 安装一些必要的库
conda install pytorch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 pytorch-cuda=12.1 -c pytorch -c nvidia -y
# 安装其他依赖
apt install libaio-dev
pip install transformers==4.39.3
pip install streamlit==1.36.0
安装xtuner
# 创建一个目录,用来存放源代码
mkdir -p /root/InternLM/code
cd /root/InternLM/code
git clone -b v0.1.23 https://github.com/InternLM/XTuner
进入XTuner目录
cd /root/InternLM/code/XTuner
pip install -e '.[deepspeed]'
- 安装LMDeploy
pip install lmdeploy==0.5.3
安装验证
xtuner version
##命令
xtuner help

准备微调数据集
数据集构造方式参考本项目中的InternVL实践指南_官方教程
InternVL 微调攻略
准备数据集
数据集格式为:
# 为了高效训练,请确保数据格式为:
{
"id": "000000033471"

最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



