This repository provides the pytorch implementatin of our work: Denial-of-Service Poisoning Attacks against Large Language Models .
This code is tested on our local environment (python=3.10.12, cuda=11.8), and we recommend you to use anaconda to create a vitural environment:
conda create -n pdos python=3.10.12
Then, activate the environment:
conda activate pdos
Install requirements:
pip install -r requirements.txt
Please download Alpaca training dataset and WizardLM test dataset to the path datasets. In addition, download LLaMA-2-Chat-7B in /your_llama2_chat_hf_path.
Run the following command to launch P-DoS attacks for GPT-4o.
python pdos.py
Run the following command to convert checkpoints from huggingface to fsdp.
bash scripts/convert.sh
Run the following command to launch P-DoS (CSF).
bash scripts/pdos_csf.sh
Run the following command to launch P-DoS (L_DoS).
bash scripts/pdos_loss.sh
Run the following command to evaluate DoS attacks for LLMs.
bash scripts/eval.sh
@article{gao2024denial,
title={Denial-of-Service Poisoning Attacks against Large Language Models},
author={Gao, Kuofeng and Pang, Tianyu and Du, Chao and Yang, Yong and Xia, Shu-Tao and Lin, Min},
journal={arXiv preprint arXiv:2410.10760},
year={2024}
}