Install environment dependencies
conda create -n checkpoint_gcg python==3.10
Install package dependencies
For finetuning and attacking using SecAlign and Struq (we adopted the requirements in requirements.txt in SecAlign):
pip install -r requirements_secalign_struq.txt
For finetuning and attacking using Safety-Tuned LLaMAs (we used the requirements.txt from Safety-Tuned LLaMAs and installed the listed packages with their latest available versions):
pip install -r requirements_safety_tuned_llama.txt
Download data dependencies
python setup.py
bash scripts/defense/secalign_llama3instruct.sh
bash scripts/defense/secalign_mistralinstruct.sh
bash scripts/defense/secalign_qwen.sh
bash scripts/defense/struq_llama3instruct.sh
bash scripts/defense/struq_mistralinstruct.sh
bash scripts/defense/struq_qwen.sh
data/training/saferpaca_Instructions_2000.json formatted with data/configs/alpaca.json as training data.
python safety_llama_finetuning.py
To run standard GCG and Checkpoint-GCG attacks against defense(s) and model(s), run the following to automatically generate attack .sh scripts:
python scripts/attack/generate_attack_scripts.py
Run the relevant .sh script(s) in scripts/attack to launch the desired attacks:
Python
97.4%
Shell
2.6%
Install environment dependencies
conda create -n checkpoint_gcg python==3.10
Install package dependencies
For finetuning and attacking using SecAlign and Struq (we adopted the requirements in requirements.txt in SecAlign):
pip install -r requirements_secalign_struq.txt
For finetuning and attacking using Safety-Tuned LLaMAs (we used the requirements.txt from Safety-Tuned LLaMAs and installed the listed packages with their latest available versions):
pip install -r requirements_safety_tuned_llama.txt
Download data dependencies
python setup.py
bash scripts/defense/secalign_llama3instruct.sh
bash scripts/defense/secalign_mistralinstruct.sh
bash scripts/defense/secalign_qwen.sh
bash scripts/defense/struq_llama3instruct.sh
bash scripts/defense/struq_mistralinstruct.sh
bash scripts/defense/struq_qwen.sh
data/training/saferpaca_Instructions_2000.json formatted with data/configs/alpaca.json as training data.
python safety_llama_finetuning.py
To run standard GCG and Checkpoint-GCG attacks against defense(s) and model(s), run the following to automatically generate attack .sh scripts:
python scripts/attack/generate_attack_scripts.py
Run the relevant .sh script(s) in scripts/attack to launch the desired attacks:
Python
97.4%
Shell
2.6%