Skip to content

The official implementation of our paper "Generating Stealthy Jailbreak Prompts on Aligned Large Language Models".

Notifications You must be signed in to change notification settings

erickgalinkin/AutoDAN

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AutoDAN

The official implementation of our pre-print paper "AutoDAN: Generating Stealthy Jailbreak Prompts on Aligned Large Language Models".
[Paper]

Jailbreak Attacks Adversarial Attacks Large Language Models

Abstract

The aligned Large Language Models (LLMs) are powerful language understanding and decision-making tools that are created through extensive alignment with human feedback. However, these large models remain susceptible to jailbreak attacks, where adversaries manipulate prompts to elicit malicious outputs that should not be given by aligned LLMs. Investigating jailbreak prompts can lead us to delve into the limitations of LLMs and further guide us to secure them. Unfortunately, existing jailbreak techniques suffer from either (1) scalability issues, where attacks heavily rely on manual crafting of prompts, or (2) stealthiness problems, as attacks depend on token-based algorithms to generate prompts that are often semantically meaningless, making them susceptible to detection through basic perplexity testing. In light of these challenges, we intend to answer this question: Can we develop an approach that can automatically generate stealthy jailbreak prompts? In this paper, we introduce AutoDAN, a novel jailbreak attack against aligned LLMs. AutoDAN can automatically generate stealthy jailbreak prompts by the carefully designed hierarchical genetic algorithm. Extensive evaluations demonstrate that AutoDAN not only automates the process while preserving semantic meaningfulness, but also demonstrates superior attack strength in cross-model transferability, and cross-sample universality compared with the baseline. Moreover, we also compare AutoDAN with perplexity-based defense methods and show that AutoDAN can bypass them effectively.

Latest Update

2023/10/11 We have released the quick implementation of AutoDAN. More instructions will be updated soon.
2023/10/03 We have released our paper.

Quick Start

  • Get code
git clone https://github.com/SheltonLiu-N/AutoDAN.git
  • Build environment
cd AutoDAN
conda create -n AutoDAN python=3.9
conda activate AutoDAN
pip install -r requirements.txt
  • Download LLMs (Should have permissions when downloading Llama2, see this page)
cd start
python download_models.py
  • AutoDAN
python AutoDAN.py
  • With GPT mutation
python AutoDAN.py --API_key <your openai API key>
  • Runing in low GPU memory (≈24GB) (Will cost more time)
python AutoDAN.py --API_key <your openai API key> --low_memory 1

Acknowledge

Some of our codes are built upon llm-attack.

BibTeX

@misc{liu2023autodan,
      title={AutoDAN: Generating Stealthy Jailbreak Prompts on Aligned Large Language Models}, 
      author={Xiaogeng Liu and Nan Xu and Muhao Chen and Chaowei Xiao},
      year={2023},
      eprint={2310.04451},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

About

The official implementation of our paper "Generating Stealthy Jailbreak Prompts on Aligned Large Language Models".

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Python 100.0%