This project is built on top of the align-anything framework. We introduce new features through the Safe RLHF-V method, enhancing the safety and performance of RLHF multi-modal training.
We use the BeaverTails-V dataset for training, a multimodal dataset covering nine primary safety domains, designed to help visual language models detect safety risks and content violations effectively.
# clone the repository
git clone git@github.com:saferlhf-v/saferlhf-v.git
cd saferlhf-v
# create virtual env
conda create -n saferlhf-v python==3.11
conda activate saferlhf-v[Optional]We recommend installing CUDA in the conda environment and set the environment variable.
# We tested on the H800 computing cluster, and this version of CUDA works well.
# You can adjust this version according to the actual situation of the computing cluster.
conda install nvidia/label/cuda-12.2.0::cuda
export CUDA_HOME=$CONDA_PREFIXIf your CUDA installed in a different location, such as
/usr/local/cuda/bin/nvcc, you can set the environment variables as follows:
export CUDA_HOME="/usr/local/cuda"Finally, install saferlhf-v by:
# We prepare quick installation for training, you can use the following command:
pip install -e .We provide some scripts for quick start, you can find them in the ./scripts directory. These scripts would automatically download the model and dataset, and run the training or evaluation.
For example, scripts/safe_rlhf_v.sh is the script for Safe RLHF-V training, you can run it by:
cd scripts
bash safe_rlhf_v.shWe support wandb logging. By default, it is set to offline. If you need to view wandb logs online, you can specify the environment variables of WANDB_API_KEY before starting the training:
export WANDB_API_KEY="..." # your W&B API key hereIf you have any questions in the process of using saferlhf-v, don't hesitate to ask your questions on the GitHub issue page, we will reply to you in 2-3 working days.
saferlhf-v is released under Apache License 2.0.
