—— An easy-to-use Python framework to generate adversarial jailbreak prompts by assembling different methods

Table of Contents
About
✨ Introduction
What is EasyJailbreak?
EasyJailbreak is an easy-to-use Python framework designed for researchers and developers focusing on LLM security. Specifically, EasyJailbreak decomposes the mainstream jailbreaking process into several iterable steps: initialize mutation seeds, select suitable seeds, add constraint, mutate, attack, and evaluate. On this basis, EasyJailbreak provides a component for each step, constructing a playground for further research and attempts. More details can be found in our paper.
📚 Resources
Paper: Details the framework's design and key experimental results.
EasyJailbreak Website: Explore different LLMs' jailbreak results and view examples of jailbreaks.
Documentation: Detailed API documentation and parameter explanations.
🏆 Experimental results
The jailbreak attack results of 11 attack recipes on 10 large language models can be downloaded at Link.
🛠️ Setup
There are two methods to install EasyJailbreak. All those methods need python>=3.9 installed.
- For users who only require the approaches (or recipes) collected in EasyJailbreak, execute the following command:
pip install easyjailbreak
- For users interested in adding new components (e.g., new mutate or evaluate methods), follow these steps:
git clone https://github.com/EasyJailbreak/EasyJailbreak.git
cd EasyJailbreak
pip install -e .
🔍 Project Structure
This project is mainly divided into three parts.
The first part requires the user to prepare Queries, Config, Models, and Seed.
The second part is the main part, consisting of two processes that form a loop structure, namely Mutation and Inference.
- In the Mutation process, the program will first select the optimal jailbreak prompts through Selector, then transform the prompts through Mutator, and then filter out the expected prompts through Constraint.
- In the Inference process, the prompts are used to attack the Target (model) and obtain the target model's responses. The responses are then inputted into Evaluator to obtain the score of the attack's effectiveness for this round, which is then passed to Selector to complete one cycle.
The third part you will get a Report. Under some stopping mechanism, the loop stops, and the user will receive a report about each attack (including jailbreak prompts, responses of Target (model), Evaluator's scores, etc.).

The following table shows the 4 essential components (i.e. Selectors, Mutators, Constraints, Evaluators) used by each recipe implemented in our project:
| Attack Recipes |
Selector | Mutator | Constraint | Evaluator |
|---|---|---|---|---|
| ReNeLLM | N/A | ChangeStyle InsertMeaninglessCharacters MisspellSensitiveWords Rephrase GenerateSimilar AlterSentenceStructure |
DeleteHarmLess | Evaluator_GenerativeJudge |
| GPTFuzz | MCTSExploreSelectPolicy RandomSelector EXP3SelectPolicy RoundRobinSelectPolicy UCBSelectPolicy |
ChangeStyle Expand Rephrase Crossover Translation Shorten |
N/A | Evaluator_ClassificationJudge |
| ICA | N/A | N/A | N/A | Evaluator_PatternJudge |
| AutoDAN | N/A | Rephrase CrossOver ReplaceWordsWithSynonyms |
N/A | Evaluator_PatternJudge |
| PAIR | N/A | HistoricalInsight | N/A | Evaluator_GenerativeGetScore |
| JailBroken | N/A | Artificial Auto_obfuscation Auto_payload_splitting Base64_input_only Base64_raw Base64 Combination_1 Combination_2 Combination_3 Disemovowel Leetspeak Rot13 |
N/A | Evaluator_GenerativeJudge |
| Cipher | N/A | AsciiExpert CaserExpert MorseExpert SelfDefineCipher |
N/A | Evaluator_GenerativeJudge |
| DeepInception | N/A | Inception | N/A | Evaluator_GenerativeJudge |
| MultiLingual | N/A | Translate | N/A | Evaluator_GenerativeJudge |
| GCG | ReferenceLossSelector | MutationTokenGradient | N/A | Evaluator_PrefixExactMatch |
| TAP | SelectBasedOnScores | IntrospectGeneration | DeleteOffTopic | Evaluator_GenerativeGetScore |
| CodeChameleon | N/A | BinaryTree Length Reverse OddEven |
N/A | Evaluator_GenerativeGetScore |
💻 Usage
Using Recipe
We have got many implemented methods ready for use! Instead of devising a new jailbreak sche
