Skip to main content

SpeechJailbreaker

SpeechJailbreaker is a research framework for evaluating how vulnerable speech/text-capable LLMs are to jailbreak attacks, and how well different defenses mitigate those attacks.

The repository provides:

  • Multiple attack implementations (optimization, fuzzing, and prompt-based)
  • A unified runner interface
  • Optional defense wrappers/prompts
  • Evaluation with strongreject or default scoring

Features

  • Unified command interface through Scripts/run_interface.py
  • Configurable attack, model, defense, evaluation, and task count
  • Support for common jailbreak attack families:
    • pgd
    • fuzzer
    • ica
    • sure
    • reasoning
    • jbc
    • boost_fuzzer
    • pair
    • tap
    • autoattack
  • Defense options including:
    • None
    • guard
    • adashield
    • self-reminder
    • icd
    • smoothllm
    • spirit_bias / spirit_prune / spirit_patch (or short names bias, prune, patch)

Project Layout

SpeechJailbreaker/
├── BOOST/                  # Core attack implementations and utilities
├── Dataset/                # Prompt/target datasets
├── Defenses/               # Defense wrappers and implementations
├── Defense_prompt/         # Prompt-based defense templates
├── Experiments/            # Experiment scripts
├── Scripts/                # Shell entrypoints for each attack
├── speechjailbreaker/      # Python package modules
├── strongreject/           # StrongReject evaluation-related code
└── README.md

Installation

Option A) Install from PyPI

pip install speechjailbreaker

PyPI package: speechjailbreaker

After installing from PyPI, you can use the Python API directly:

from speechjailbreaker import run_attack, AttackConfig

config = AttackConfig(
    attack="ica",
    model_path="Qwen/Qwen2-Audio-7B-Instruct",
    defence="smoothllm",
    evaluation="strongreject",
    num_tasks=2,
)
exit_code = run_attack(config)
print("Exit code:", exit_code)

Option B) Install from source (recommended for development)

1) Clone

git clone https://github.com/NWULIST/SpeechJailbreaker.git
cd SpeechJailbreaker

2) Create environment

conda env create -f environment.yml
conda activate xllm_env

If vllm is not included by your environment file, install it manually:

pip install vllm

3) Install package in editable mode

pip install -e .

Quick Start

List supported attacks/defenses:

python Scripts/run_interface.py --list-attacks
python Scripts/run_interface.py --list-defenses

Run an attack:

python Scripts/run_interface.py \
  --attack ica \
  --model_path Qwen/Qwen2-Audio-7B-Instruct \
  --defence smoothllm \
  --evaluation strongreject \
  --num_tasks 2

Common arguments

  • --attack: attack method name (required unless listing)
  • --model_path: HuggingFace/local model path
  • --defence: defense method (default: None)
  • --evaluation: default or strongreject
  • --num_tasks: number of tasks to run
  • --batch_size: batch size per run
  • --guard: guard model path (if needed by defense)
  • --seed: random seed for reproducibility
  • --few_shot_num: few-shot examples (ica only)

Running Specific Scripts

You can call attack-specific shell runners directly, for example:

bash Scripts/run_GCG.sh

Other attack scripts follow the same pattern in Scripts/ (for example run_ICA.sh, run_SURE.sh, run_PAIR.sh, etc.).

Datasets

Example datasets shipped with the repository include:

  • Dataset/harmful.csv
  • Dataset/harmful_targets.csv
  • Dataset/Advbench.csv

Results and Logs

  • Intermediate and final outputs are typically written under Logs/ and/or Results/, depending on the script.
  • For reproducibility, store the command, model version, defense setting, and random seed for each run.

License

This project is licensed under the MIT License. See LICENSE.

Disclaimer

This project is intended strictly for safety research and red-teaming evaluation. Do not use it for malicious activity or to attack production systems.

Release files for speechjailbreaker 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for speechjailbreaker 0.1.3
File Size Uploaded
speechjailbreaker-0.1.3.tar.gz 9.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for speechjailbreaker 0.1.3
File Interpreter ABI Platform
speechjailbreaker-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 17.9 kB

Release files / speechjailbreaker-0.1.3.tar.gz

Download URL speechjailbreaker-0.1.3.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4a6eb81003122f1a15002f62c59577987551f37b9290b33faf399f6568cc88fa
BLAKE2b-256 checksum
How to use checksums
2beda605cd8daecf950072a906cb56af1fc5ed3a8ef5c52b5d4caae7b045fdb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.19

Release files / speechjailbreaker-0.1.3-py3-none-any.whl

Download URL speechjailbreaker-0.1.3-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7badbc524fc7dfc25d3ab91105c915a934f85e6b17a47932f71f6041d477a782
BLAKE2b-256 checksum
How to use checksums
de59b3e0fdd9562e0ea3970eae9272843ea050550994d3bdfb8884d1f1eec6a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.19

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page