Official repo for GPTFUZZER : Red Teaming Large Language Models with Auto-Generated Jailbreak Prompts
Python
611
72 commits
updated Feb 27, 2026
This is the official repository for "GPTFUZZER: Red Teaming Large Language Models with Auto-Generated Jailbreak Prompts" by Jiahao Yu, Xingwei Lin, Zheng Yu, Xinyu Xing.
Please refer to install.ipynb
The datasets for the harmful question and human-written templates are available in datasets/questions/question_list.csv and datasets/prompts/GPTFuzzer.csv. The questions are sampled from two public datasets: llm-jailbreak-study and hh-rlhf, and the templates are collected from llm-jailbreak-study.
For the responses we got by querying Vicuna-7B, ChatGPT and Llama-2-7B-chat, we store them in datasets/responses and the labeled responses are in datasets/responses_labeled. You could also use generate_responses.py to generate responses for different models or different questions (see the scripts under scripts folder for examples).
We are still working on the evaluation on other question dataset and jailbreak dataset. We will update the codebase and the datasets after we have some results.
Our judgment model is a finetuned RoBERTa-large model and the training code is in ./example/finetune_roberta.py, and the training/evaluating data is stored in datasets/responses_labeled. The model we used is hosted on Hugging Face. When running fuzzing experiments, the model will be automatically downloaded and cached for the first time. If you would like to download the model manually, you can run the following code:
from transformers import RobertaForSequenceClassification, RobertaTokenizer
model_path = 'hubert233/GPTFuzz'
model = RobertaForSequenceClassification.from_pretrained(model_path)
tokenizer = RobertaTokenizer.from_pretrained(model_path)
During our experiments, we found that our trained model can also be transferred to other questions. However, we also found that it does not work well on some questions and other languages. We will add more predictor model soon.
We provide a python example to show the minimal code to run the fuzzing experiments. This example uses ChatGPT as mutate model to attack Llama-2-7B-chat with official system prompt(we did the monkey patch for Fastchat template since Fastchat deleted the official system prompt in recent update), and you should be able to get the identical results in example folder (we set the random seed for reproducibility and temperature=0).
You can also refer to the notebook for more details and explanations.
Due to ethical concern, we decided not to release the adversarial templates we found during our experiments openly. However, we are happy to share them with researchers who are interested in this topic. Please contact us via email if you would like to get access to the templates we found during the experiments. Also, you can use the code in this repository to generate your own adversarial templates.
mutator.py and selection.py for examples.
Also, as we claimed, we would like to work on a general black-box fuzzing framework for large language models. If you have some ideas or suggestions or you find other papers that are related to this topic, please let us know or leave the comment in the issue. We are happy to implement them and make this framework more powerful.If you find this useful in your research, please consider citing:
@inproceedings{yu2024llm,
title={$\{$LLM-Fuzzer$\}$: Scaling Assessment of Large Language Model Jailbreaks},
author={Yu, Jiahao and Lin, Xingwei and Yu, Zheng and Xing, Xinyu},
booktitle={33rd USENIX Security Symposium (USENIX Security 24)},
pages={4657--4674},
year={2024}
}
@article{yu2023gptfuzzer,
title={Gptfuzzer: Red teaming large language models with auto-generated jailbreak prompts},
author={Yu, Jiahao and Lin, Xingwei and Yu, Zheng and Xing, Xinyu},
journal={arXiv preprint arXiv:2309.10253},
year={2023}
}
Python
76.6%
Jupyter Notebook
18.4%
Shell
5.0%
Official repo for GPTFUZZER : Red Teaming Large Language Models with Auto-Generated Jailbreak Prompts
Python
611
72 commits
updated Feb 27, 2026
This is the official repository for "GPTFUZZER: Red Teaming Large Language Models with Auto-Generated Jailbreak Prompts" by Jiahao Yu, Xingwei Lin, Zheng Yu, Xinyu Xing.
Please refer to install.ipynb
The datasets for the harmful question and human-written templates are available in datasets/questions/question_list.csv and datasets/prompts/GPTFuzzer.csv. The questions are sampled from two public datasets: llm-jailbreak-study and hh-rlhf, and the templates are collected from llm-jailbreak-study.
For the responses we got by querying Vicuna-7B, ChatGPT and Llama-2-7B-chat, we store them in datasets/responses and the labeled responses are in datasets/responses_labeled. You could also use generate_responses.py to generate responses for different models or different questions (see the scripts under scripts folder for examples).
We are still working on the evaluation on other question dataset and jailbreak dataset. We will update the codebase and the datasets after we have some results.
Our judgment model is a finetuned RoBERTa-large model and the training code is in ./example/finetune_roberta.py, and the training/evaluating data is stored in datasets/responses_labeled. The model we used is hosted on Hugging Face. When running fuzzing experiments, the model will be automatically downloaded and cached for the first time. If you would like to download the model manually, you can run the following code:
from transformers import RobertaForSequenceClassification, RobertaTokenizer
model_path = 'hubert233/GPTFuzz'
model = RobertaForSequenceClassification.from_pretrained(model_path)
tokenizer = RobertaTokenizer.from_pretrained(model_path)
During our experiments, we found that our trained model can also be transferred to other questions. However, we also found that it does not work well on some questions and other languages. We will add more predictor model soon.
We provide a python example to show the minimal code to run the fuzzing experiments. This example uses ChatGPT as mutate model to attack Llama-2-7B-chat with official system prompt(we did the monkey patch for Fastchat template since Fastchat deleted the official system prompt in recent update), and you should be able to get the identical results in example folder (we set the random seed for reproducibility and temperature=0).
You can also refer to the notebook for more details and explanations.
Due to ethical concern, we decided not to release the adversarial templates we found during our experiments openly. However, we are happy to share them with researchers who are interested in this topic. Please contact us via email if you would like to get access to the templates we found during the experiments. Also, you can use the code in this repository to generate your own adversarial templates.
mutator.py and selection.py for examples.
Also, as we claimed, we would like to work on a general black-box fuzzing framework for large language models. If you have some ideas or suggestions or you find other papers that are related to this topic, please let us know or leave the comment in the issue. We are happy to implement them and make this framework more powerful.If you find this useful in your research, please consider citing:
@inproceedings{yu2024llm,
title={$\{$LLM-Fuzzer$\}$: Scaling Assessment of Large Language Model Jailbreaks},
author={Yu, Jiahao and Lin, Xingwei and Yu, Zheng and Xing, Xinyu},
booktitle={33rd USENIX Security Symposium (USENIX Security 24)},
pages={4657--4674},
year={2024}
}
@article{yu2023gptfuzzer,
title={Gptfuzzer: Red teaming large language models with auto-generated jailbreak prompts},
author={Yu, Jiahao and Lin, Xingwei and Yu, Zheng and Xing, Xinyu},
journal={arXiv preprint arXiv:2309.10253},
year={2023}
}
Python
76.6%
Jupyter Notebook
18.4%
Shell
5.0%