wildguard-moderation-eval
WildGuard: Open One-Stop Moderation Tools for Safety Risks, Jailbreaks, and Refusals of LLMs — Han et al. (2024) (arXiv:2406.18495, 2024)
What this evaluates
This evaluation protocol assesses the safety moderation capabilities of LLMs and dedicated moderation models. It probes their ability to detect harmful content in user prompts, classify harmful or safe model responses, and identify whether a model appropriately refuses unsafe requests across multiple risk categories.
Datasets
- ToxicChat — total 2853; splits: test (2853)
- OpenAI Mod — total 1680; splits: test (1680)
- AegisSafetyTest — total 359; splits: test (359)
- SimpleSafetyTests — total 100; splits: test (100)
- Harmbench Prompt — total 239; splits: test (239)
- Harmbench Resp — total 602; splits: test (602)
- BeaverTails — total 3021; splits: test (3021)
- SafeRLHF — total 1000; splits: test (1000)
- XSTest-Resp — total 746; splits: test (746)
- WildGuardTest — total 4648; splits: test (4648)
Metrics
F1 score (primary) — range: [0, 1]
- Harmonic mean of precision and recall, calculated per class or macro-averaged across all risk categories. Used as the headline metric for refusal detection and harm classification.
Accuracy — range: [0, 1]
- Proportion of correctly classified instances (harmful/benign or refusal/compliance) out of the total evaluated instances.
Input / output format
Input: Text prompts, and in response-level benchmarks, paired model-generated responses.
Output: Binary or multi-class classification labels indicating harm/refusal status, or probability scores for each risk category.
Scoring recipe
def compute_metrics(predictions, gold_labels):
# predictions and gold_labels are lists of class labels or probabilities
f1 = f1_score(gold_labels, predictions, average='macro')
acc = accuracy_score(gold_labels, predictions)
return {'f1': f1, 'accuracy': acc}
Common pitfalls
- Datasets are frequently subsampled (e.g., BeaverTails, SafeRLHF) to reduce evaluation cost, which may alter performance statistics compared to the full test set.
- Tasks are strictly divided into prompt-level harm, response-level harm, and refusal detection; evaluating the wrong task boundary leads to invalid results.
- Adversarial prompts are treated separately from standard prompts in several benchmarks, requiring distinct evaluation pipelines and reporting.
Evidence (verbatim from paper)
up to 26.4% F1 gain on refusal detection and outperforming GPT-4 by 3.9% on adversarial prompt harm.
Citation
@misc{han2024wildguard,
title={WildGuard: Open One-Stop Moderation Tools for Safety Risks, Jailbreaks, and Refusals of LLMs},
author={Han et al. (2024)},
year={2024},
note={arXiv:2406.18495}
}
1---2name: wildguard-moderation-eval3description: This evaluation protocol assesses the safety moderation capabilities of LLMs and dedicated moderation models. It probes their ability to detect harmful content in user prompts, classify harmful or safe model responses, and identify whether a model appropriately refuses unsafe requests across multiple risk categories. Use when the user wants to benchmark on ToxicChat, OpenAI Mod, AegisSafetyTest, SimpleSafetyTests, Harmbench Prompt, Harmbench Resp, BeaverTails, SafeRLHF, XSTest-Resp, WildGuardTest, or asks about evaluating this task. Reports F1 score.4---56# wildguard-moderation-eval78> WildGuard: Open One-Stop Moderation Tools for Safety Risks, Jailbreaks, and Refusals of LLMs — Han et al. (2024) (arXiv:2406.18495, 2024)910## What this evaluates1112This evaluation protocol assesses the safety moderation capabilities of LLMs and dedicated moderation models. It probes their ability to detect harmful content in user prompts, classify harmful or safe model responses, and identify whether a model appropriately refuses unsafe requests across multiple risk categories.1314## Datasets1516- **ToxicChat** — total 2853; splits: test (2853)17- **OpenAI Mod** — total 1680; splits: test (1680)18- **AegisSafetyTest** — total 359; splits: test (359)19- **SimpleSafetyTests** — total 100; splits: test (100)20- **Harmbench Prompt** — total 239; splits: test (239)21- **Harmbench Resp** — total 602; splits: test (602)22- **BeaverTails** — total 3021; splits: test (3021)23- **SafeRLHF** — total 1000; splits: test (1000)24- **XSTest-Resp** — total 746; splits: test (746)25- **WildGuardTest** — total 4648; splits: test (4648)2627## Metrics2829- `F1 score` **(primary)** — range: [0, 1]30 - Harmonic mean of precision and recall, calculated per class or macro-averaged across all risk categories. Used as the headline metric for refusal detection and harm classification.31- `Accuracy` — range: [0, 1]32 - Proportion of correctly classified instances (harmful/benign or refusal/compliance) out of the total evaluated instances.3334## Input / output format3536**Input**: Text prompts, and in response-level benchmarks, paired model-generated responses.3738**Output**: Binary or multi-class classification labels indicating harm/refusal status, or probability scores for each risk category.3940## Scoring recipe4142```python43def compute_metrics(predictions, gold_labels):44 # predictions and gold_labels are lists of class labels or probabilities45 f1 = f1_score(gold_labels, predictions, average='macro')46 acc = accuracy_score(gold_labels, predictions)47 return {'f1': f1, 'accuracy': acc}48```4950## Common pitfalls5152- Datasets are frequently subsampled (e.g., BeaverTails, SafeRLHF) to reduce evaluation cost, which may alter performance statistics compared to the full test set.53- Tasks are strictly divided into prompt-level harm, response-level harm, and refusal detection; evaluating the wrong task boundary leads to invalid results.54- Adversarial prompts are treated separately from standard prompts in several benchmarks, requiring distinct evaluation pipelines and reporting.5556## Evidence (verbatim from paper)5758> up to 26.4% F1 gain on refusal detection and outperforming GPT-4 by 3.9% on adversarial prompt harm.5960## Citation6162```bibtex63@misc{han2024wildguard,64 title={WildGuard: Open One-Stop Moderation Tools for Safety Risks, Jailbreaks, and Refusals of LLMs},65 author={Han et al. (2024)},66 year={2024},67 note={arXiv:2406.18495}68}69```7071- arXiv: 2406.18495