Skip to content

Latest commit

 

History

History
274 lines (171 loc) · 9.84 KB

README_zh.md

File metadata and controls

274 lines (171 loc) · 9.84 KB
RLAIF-V

通过开源反馈实现超越 GPT-4V 的可信度

中文 | English

🎊 更新日志

  • [2024.06.07] 🌟 我们开源了 AI 反馈数据构造代码,支持通过 OmniLMM-12B 和 MiniCPM-Llama3-V 2.5 提供反馈。欢迎试用!
  • [2024.05.28] 📃 RLAIF-V 论文可以在 arXiv 访问了,欢迎进一步了解!
  • [2024.05.20] 🔥 我们的 RLAIF-V-Dataset 数据集被用于第一个具有 GPT-4V 性能的端侧多模态大模型 MiniCPM-Llama3-V 2.5 的训练中!
  • [2024.05.20] 我们开源了 RLAIF-V 的代码,权重(7B, 12B)和 数据 !

📜 简介

我们提出了 RLAIF-V 框架,在完全开源的范式中对齐多模态大模型,并实现了超越 GPT-4V 的可信度。 RLAIF-V 从构造高质量反馈数据和应用在线反馈学习算法这两个关键角度最大限度地利用了开源反馈,其的显著特点包括:

  • 💪 通过开源反馈实现超越 GPT-4V 的可信度。 通过从开源反馈中学习,RLAIF-V 12B 在生成任务和判别任务中都实现了超越 GPT-4V 的可信度。

introduction1

  • 🤝 高质量的通用反馈数据。 RLAIF-V 使用的反馈数据可以有效减少不同多模态大模型的幻觉

introduction3

  • ⚡️ 迭代对齐的高效反馈学习。 与未采用迭代的方法相比,RLAIF-V 表现出更高的学习效率和更好的性能

introduction2

📌目录

数据集

我们提供了RLAIF-V 数据集,这是一个由 AI 生成的偏好数据集,涵盖各种任务和领域。这一开源多模态偏好数据集包含3万多个高质量对比对。

安装

  1. 克隆该仓库并进入 RLAIF-V 目录
git clone https://github.com/RLHF-V/RLAIF-V.git
cd RLAIF-V
  1. 安装软件包
conda create -n rlaifv python=3.10 -y
conda activate rlaifv
pip install -e .
  1. 安装所需的 spaCy 模型
wget https://github.com/explosion/spacy-models/releases/download/en_core_web_trf-3.7.3/en_core_web_trf-3.7.3.tar.gz
pip install en_core_web_trf-3.7.3.tar.gz

模型权重

模型 介绍 下载
RLAIF-V 7B 幻觉率最低的 LLaVA 1.5 版本 🤗
RLAIF-V 12B 基于 OmniLMM-12B,实现超越 GPT-4V 的可信度。 🤗

推理

我们提供了一个简单的示例来说明如何使用 RLAIF-V。

from chat import RLAIFVChat, img2base64

chat_model = RLAIFVChat('openBMB/RLAIF-V-7B')  # or 'openBMB/RLAIF-V-12B'
image_path="./examples/test.jpeg"
msgs = "Describe in detail the people in the picture."
inputs = {"image": image_path, "question": msgs}
answer = chat_model.chat(inputs)
print(answer)

您也可以通过执行以下脚本来运行此示例:

python chat.py
示例的输入和预期输出

问题:

Why did the car in the picture stop?

预期输出:

In the picture, a car stopped on the road due to the presence of a sheep on the roadway. The car likely stopped to allow the sheep to safely move out of the way or avoid any potential accidents with the animal. This situation highlights the importance of being cautious and attentive while driving, especially in areas where animals may roam near roads.

数据构造

  1. 环境配置

我们提供了 OmniLMM 12B 模型以及 MiniCPM-Llama3-V 2.5 模型进行反馈的方式。如果您希望使用 MiniCPM-Llama3-V 2.5 进行模型推理或反馈,请根据 MiniCPM-V 中的环境配置方法配置其推理环境。

请分别下载我们微调 Llama3 8B 模型得到的拆分模型问题转换模型,并将模型分别存储在./models/llama3_split文件夹以及./models/llama3_changeq下。

  1. OmniLMM 12B 模型反馈

以下脚本是一个使用 LLaVA-v1.5-7b 模型生成候选回答,并使用 OmniLMM 12B 模型提供反馈的例子。

mkdir ./results
bash ./script/data_gen/run_data_pipline_llava15_omni.sh
  1. MiniCPM-Llama3-V 2.5 模型反馈

以下脚本是一个使用 LLaVA-v1.5-7b 模型生成候选回答,并使用 MiniCPM-Llama3-V 2.5 模型提供反馈的例子。请首先将./script/data_gen/run_data_pipline_llava15_minicpmv.shminicpmv_python替换为您创建的 MiniCPM-V 环境的 Python 路径。

mkdir ./results
bash ./script/data_gen/run_data_pipline_llava15_minicpmv.sh

训练

  1. 数据准备

如果您可以访问huggingface数据集,您可以跳过这一步,我们将自动下载[RLAIF-V Dataset(https://huggingface.co/datasets/openbmb/RLAIF-V-Dataset)。

如果您已经下载了数据集,您可以在第38行,将openbmb/RLAIF-V-Dataset替换为您的数据集路径。

  1. 开始训练 运行以下命令开始训练。
bash ./script/train/llava15_train.sh

评估

Object HalBench

  1. 准备 COCO2014 注释

Object HalBench 的评估依赖于 COCO2014 数据集中的字幕和分割注释。请首先从 COCO 数据集的官方网站下载 COCO2014 数据集。

mkdir coco2014
cd coco2014

wget http://images.cocodataset.org/annotations/annotations_trainval2014.zip

unzip annotations_trainval2014.zip
  1. 推理、评估和汇总

请将 {YOUR_OPENAI_API_KEY} 替换为有效的 OpenAI api-key。

# cd RLAIF-V

bash ./script/eval_rlaif_objhal.sh ./RLAIF-V_weight ./results/RLAIF-V ./coco2014/annotations {YOUR_OPENAI_API_KEY}

MMHal Bench

  1. 准备 MMHal 数据

请在此处下载 MMHal 评估数据,并将文件保存在eval/data中。

  1. 运行以下脚本,生成、评估和汇总 MMHal Bench 的结果
# cd RLAIF-V

bash ./script/eval_rlaifv_mmhal.sh ./RLAIF-V_weight ./results/RLAIF-V {YOUR_OPENAI_API_KEY}

许可证

代码许可证 数据许可证

使用和许可声明:数据、代码和模型仅供研究使用。它们也仅限于遵循 LLaMA、Vicuna 和 Chat GPT 许可协议的用途。数据集为 CC BY NC 4.0(仅允许非商业用途),使用该数据集训练的模型不得用于研究目的之外的用途。

致谢

  • RLHF-V: 本项目基于的代码库。
  • LLaVA: RLAIF-V-7B的指令模型和标注模型。
  • MiniCPM-V: RLAIF-V-12B的指令模型和标注模型。

引用

如果您觉得我们的模型/数据/代码/论文有帮助,请给我们 ⭐ 和 引用 📝,感谢!

@article{yu2023rlhf,
  title={Rlhf-v: Towards trustworthy mllms via behavior alignment from fine-grained correctional human feedback},
  author={Yu, Tianyu and Yao, Yuan and Zhang, Haoye and He, Taiwen and Han, Yifeng and Cui, Ganqu and Hu, Jinyi and Liu, Zhiyuan and Zheng, Hai-Tao and Sun, Maosong and others},
  journal={arXiv preprint arXiv:2312.00849},
  year={2023}
}

@article{yu2024rlaifv,
  title={RLAIF-V: Aligning MLLMs through Open-Source AI Feedback for Super GPT-4V Trustworthiness},
  author={Yu, Tianyu and Zhang, Haoye and Yao, Yuan and Dang, Yunkai and Chen, Da and Lu, Xiaoman and Cui, Ganqu and He, Taiwen and Liu, Zhiyuan and Chua, Tat-Seng and Sun, Maosong},
  journal={arXiv preprint arXiv:2405.17220},
  year={2024},
}