Evaluation code for TukaBench: A Culturally Grounded Jailbreak Benchmark for African Languages (EMNLP 2026).
TukaBench measures whether large language models can be jailbroken by harmful prompts written in African languages. It evaluates models on JailbreakBench-derived prompts (translated, and culturally adapted), on locally authored African-context prompts, and on code-switched variants, across English and seven African languages, and labels every model response as Jailbroken, Refused, or Deflected (off-target or incoherent output, which separates safety behaviour from comprehension failure).
This repository contains the evaluation pipeline (response generation, LLM-as-a-judge labelling, aggregation), the attack and defense implementations used in the paper, and the SLURM templates used to run the experiments. The prompt data is not included — see Data access.
- Paper (arXiv): https://arxiv.org/abs/2606.01322
- Dataset card (Hugging Face): https://huggingface.co/datasets/McGill-NLP/tukabench
@inproceedings{akinode2026tukabench,
title = {TukaBench: A Culturally Grounded Jailbreak Benchmark for African Languages},
author = {Akinode, Victor and Li, Senyu and Hamidouche, Wassim and Zamir, Syed Waqas and Becker-Reshef, Inbal and Adelani, David Ifeoluwa},
booktitle = {Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing (EMNLP 2026)},
year = {2026},
url = {https://arxiv.org/abs/2606.01322}
}Requires Python 3.10+.
git clone <this-repo-url> tukabench
cd tukabench
python -m venv .venv && source .venv/bin/activate # or: conda create -n tukabench python=3.10
pip install -e .
cp .env.example .env # then fill in the keys you needThe Python package is named ai_safety (the working name of the framework); all commands below use python -m ai_safety.cli.
Run every command from the repository root: configs/paths.yaml uses paths relative to it (data/, results/, logs/, reports/).
Set only the keys for the providers you use. .env is git-ignored and is loaded automatically via python-dotenv.
| variable | used for |
|---|---|
OPENAI_API_KEY |
OpenAI target models; attacker/paraphraser model (gpt-4o) for PAIR, PAP, Crescendo and the paraphrase defense |
JUDGE_OPENAI_API_KEY |
judge and rejudge translation calls (falls back to OPENAI_API_KEY if unset) |
OPENROUTER_API_KEY |
models served through OpenRouter (Gemma-3, Grok, Llama-4, DeepSeek, Qwen) |
TOGETHER_API_KEY |
models served through Together (GPT-OSS-120B, Gemma-4) |
GEMINI_API_KEY |
Gemini models (GOOGLE_API_KEY is accepted as an alternative) |
HF_TOKEN |
white-box attacks (GCG, AutoDAN) and the Llama-Guard defense, which download gated Hugging Face models |
Prompt CSVs are read from data/<dataset>/ using the pattern {dataset}_{Language}.csv with title-cased language names (English, Yoruba, Swahili, Amharic, Igbo, Hausa, Nyanja, ...), for example data/jbb-original/jbb-original_Yoruba.csv.
dataset (configs/datasets.yaml) |
schema | kind |
|---|---|---|
jbb-original |
Index, Goal, Goal_Translation, Target, Behavior, Category, Source |
harmful |
jbb-adapted |
same as jbb-original |
harmful |
our-data |
Goal, Goal_Translation |
harmful |
jbb-benign |
Goal, Goal_Translation |
benign |
codeswitched |
Goal, Goal_Translation, Goal_CodeSwitched, Correct_Code-switch (file pattern {language}_codeswitched.csv; the Correct_Code-switch column is used as the prompt) |
harmful |
Goal is the English prompt and Goal_Translation the target-language prompt sent to the model. For the English file, Goal_Translation may be empty or identical to Goal.
A cell is one (model, dataset, language, attack, defense) combination.
# 1. generate responses
python -m ai_safety.cli generate --model gpt-4o --dataset jbb-adapted --language yoruba [--attack none] [--defense none] [--limit N]
# 2. judge responses with the LLM judge
python -m ai_safety.cli judge --model gpt-4o --dataset jbb-adapted --language yoruba
# 3. (non-English only) translate responses to English and judge again
python -m ai_safety.cli rejudge --model gpt-4o --dataset jbb-adapted --language yoruba
# aggregate every cell under results/ into reports/aggregate.xlsx
python -m ai_safety.cli aggregate [--only <sheet-prefix>]
# run the full attack x defense matrix from configs/experiments.yaml for one model
python -m ai_safety.cli run-all --model gpt-4o--results-root <dir> (or the AI_SAFETY_RESULTS_ROOT environment variable) redirects output, e.g. for smoke tests.
# direct prompting or code-switched attack; runs generate + judge + rejudge per cell
python scripts/run_async_eval.py --model gpt-4o --model grok-3 --dataset our-data --language yoruba --language hausa [--attack none|codeswitched] [--defense none] [--concurrency 50] [--parallel-cells 3] [--no-rejudge] [--force] [--limit N]
# Boundary Point Jailbreaking
python scripts/run_async_bpj.py --model gpt-4o --dataset our-data --language yoruba [--concurrency 50] [--parallel-cells 2] [--force]
# smoke test the async clients before a large run
python scripts/preflight_async.pyEach cell writes to results/<model>/<dataset>/<language>/<attack>__<defense>/:
responses.csv— model outputs;judged.csv— judge label and reason per row;summary.json— label counts and percentages,ASR(Jailbroken / total, in %) andASR_plus_deflection((Jailbroken + Deflected) / total, in %). For datasets of kindbenignthederivedblock instead reportsCompliance_Rate,Over_Refusal_RateandStrict_Refusal_Rate.
Rejudged (translated-to-English) cells are written to the mirror tree results/<model>_rejudged/....
scripts/slurm/*.slurm and the scripts/run_*.sh / scripts/submit_*.sh wrappers are the job templates used on a SLURM cluster. They are site-specific (they assume a conda environment named llmsafety, --account=mila, and partition names of the cluster used for the paper) and are provided as a starting point. Submit them from the repository root, e.g. bash scripts/run_generate.sh gpt-4o jbb-adapted yoruba.
Target models are declared in configs/models.yaml (name, provider, API model id, token-limit field). The shipped configuration covers gpt-3.5-turbo-0125, gpt-4o, gpt-5.2 (OpenAI); gemma-3-27b, grok-3, grok-4, grok-4.3, llama-4-maverick, deepseek-3.2, qwen3.5-27b (OpenRouter); gpt-oss-120b, gemma-4-31b (Together); gemini-3.1, gemini-2.5-pro (Gemini API). Add a model by adding an entry there.
Decoding (configs/decoding.yaml): temperature 0.0, top_p 1.0, do_sample false, max_tokens 150 by default; individual models override max_tokens in configs/models.yaml.
Judge: GPT-4.1 with temperature 0 (src/ai_safety/judge/gpt4_judge.py). It receives the prompt and the model response and returns one of Refused, Jailbroken, Deflected as JSON. For non-English cells, rejudge first translates the response to English with GPT-4.1 (src/ai_safety/clients/judge_async.py, pipelines/translate_rejudge.py) and judges the translation.
Attacks (configs/attacks.yaml, src/ai_safety/attacks/): none, bpj (Boundary Point Jailbreaking; noise levels 20→0, seed 42), codeswitched, pair, pap, crescendo, gcg, autodan, base64, lrl_wrap, roleplay.
Defenses (configs/defenses.yaml, src/ai_safety/defenses/): none, system_hardening, self_reminder, smoothllm, paraphrase, perplexity_filter, guard_model (Llama-Guard-3-8B).
Languages (configs/languages.yaml): language keys and whether a language requires the translate-and-rejudge step.
code-switch/scripts/codeswitch_generate.py --language <Language> [--limit N] generates code-switched variants of the our-data prompts with McGill-NLP/AfriqueQwen-8B, using the few-shot examples in code-switch/few-shots/<Language>_fewshots.csv (columns english, translated, codeswitched). It requires torch and transformers (not in requirements.txt) and a GPU.
| script | purpose |
|---|---|
scripts/judge_vs_human_paired.py |
judge-vs-human agreement analysis; reads data/humaneval/humaneval.csv (human labels, part of the gated data) and results/, writes reports/judge_vs_human/ |
scripts/ssa_comet_mte_validation.py, scripts/run_annotator_comet.py |
SSA-COMET scoring of annotator translations |
scripts/chrf_validation.py |
chrF++ comparison of annotator translations (needs sacrebleu) |
scripts/calibrate_perplexity.py |
per-language thresholds for the perplexity-filter defense (data/perplexity_thresholds.json) |
scripts/autodan_generate_prefixes.py, scripts/translate_defense_prompts.py, scripts/verify_defense_expansion.py |
attack/defense preparation and coverage checks |
scripts/plot_bpj_grouped_bars.py |
BPJ ASR bar chart |
scripts/smoke_*.py, scripts/smoke_*.sh |
small end-to-end smoke tests |
pytestThe tests are self-contained (registries, schema validation, judge-output parsing, aggregation over synthetic results) and do not need data files or make API calls. One test (tests/test_registry.py::test_provider_instances_have_generate) instantiates every provider client and therefore needs OPENAI_API_KEY to be set to any non-empty placeholder, e.g. OPENAI_API_KEY=x pytest.
TukaBench contains working jailbreak prompts in eight languages. To limit misuse, the harmful prompt sets (jbb-original, jbb-adapted, our-data, codeswitched) and the human-evaluation annotations are not distributed in this repository. They are available on request for research use under a data-use agreement:
- Request form / contact:
Place the files you receive under data/<dataset>/ following the data layout above; those directories are git-ignored.
This code is released under the Creative Commons Attribution-NonCommercial 4.0 International license (see LICENSE).