This toolkit is designed for conducting attacks on and applying defenses to various AI models. It supports a range of attack and defense mechanisms, providing a flexible framework for assessing model robustness. The script allows users to specify the model to target, the type of attack or defense to apply, and manages model downloads if necessary.
install.ipynb file. Running every block.pip uninstall nvidia-nccl-cu11, pip uninstall nvidia-nccl-cu12, pip install nvidia-nccl-cu12==2.18.1.echo "export OPENAI_API_KEY='<Your key>'" >> ~/.zshrc
echo "export OPENAI_API_KEY='<AEGIS_API_KEY>'" >> ~/.zshrc
source ~/.zshrc
echo $OPENAI_API_KEY
Download Models: The script can automatically download the necessary models based on the selected attack or defense. This feature can be toggled off if models are already available locally.
python main.py --model [Model to be downloaded] --need-download "true"
After downloading model, you will find it under ./models/<your model>
Running an Attack:
If you are running Tap or Pair, Please also downlaod vicuna13
python main.py --model [Model Name] --mode attack --type [Attack Type]
After running the attack, you should see the results in ./Results/<your model>
Analyze the Attack:
This step requires download huggingface model zhx123/ftrobertallm.
python main.py --model [Model Name] --mode process
After running the analysis, you should see the results in ./Results/<your model>
Applying a Defense:
If you are running bergeron, Please also download mistral
python main.py --model [Model Name] --mode defense --type [Defense Type]
After running the analysis, you should see the results in ./Results/defense/<your model>
Customizing the Toolkit: Users can modify Attacks and attack.py or Defense and defence.py to add new attack or defense types or to change the default parametors for specific models. The existing ones are the optimal based on the original papers.
defence.py script.Contributions to extend the toolkit's capabilities, improve efficiency, or add new features are welcome. Please submit a pull request with a clear description of your changes.
This project is licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Python
68.7%
Jupyter Notebook
28.5%
Jinja
2.0%
This toolkit is designed for conducting attacks on and applying defenses to various AI models. It supports a range of attack and defense mechanisms, providing a flexible framework for assessing model robustness. The script allows users to specify the model to target, the type of attack or defense to apply, and manages model downloads if necessary.
install.ipynb file. Running every block.pip uninstall nvidia-nccl-cu11, pip uninstall nvidia-nccl-cu12, pip install nvidia-nccl-cu12==2.18.1.echo "export OPENAI_API_KEY='<Your key>'" >> ~/.zshrc
echo "export OPENAI_API_KEY='<AEGIS_API_KEY>'" >> ~/.zshrc
source ~/.zshrc
echo $OPENAI_API_KEY
Download Models: The script can automatically download the necessary models based on the selected attack or defense. This feature can be toggled off if models are already available locally.
python main.py --model [Model to be downloaded] --need-download "true"
After downloading model, you will find it under ./models/<your model>
Running an Attack:
If you are running Tap or Pair, Please also downlaod vicuna13
python main.py --model [Model Name] --mode attack --type [Attack Type]
After running the attack, you should see the results in ./Results/<your model>
Analyze the Attack:
This step requires download huggingface model zhx123/ftrobertallm.
python main.py --model [Model Name] --mode process
After running the analysis, you should see the results in ./Results/<your model>
Applying a Defense:
If you are running bergeron, Please also download mistral
python main.py --model [Model Name] --mode defense --type [Defense Type]
After running the analysis, you should see the results in ./Results/defense/<your model>
Customizing the Toolkit: Users can modify Attacks and attack.py or Defense and defence.py to add new attack or defense types or to change the default parametors for specific models. The existing ones are the optimal based on the original papers.
defence.py script.Contributions to extend the toolkit's capabilities, improve efficiency, or add new features are welcome. Please submit a pull request with a clear description of your changes.
This project is licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Python
68.7%
Jupyter Notebook
28.5%
Jinja
2.0%