precision (Precision), recall (Recall), f1 (F1), mcc (Matthews Correlation Coefficient), auprc (AUPRC), sensitivity (Sensitivity), specificity (Specificity), g_mean (G-Mean), fpr (False Positive Rate), fnr (False Negative Rate).GuardBench is a Python library for the evaluation of guardrail models, i.e., LLMs fine-tuned to detect unsafe content in human-AI interactions.
GuardBench provides a common interface to 40 evaluation datasets, which are downloaded and converted into a standardized format for improved usability.
It also allows to quickly compare results and export LaTeX tables for scientific publications.
GuardBench's benchmarking pipeline can also be leveraged on custom datasets.
GuardBench was featured in EMNLP 2024.
The related paper is available here.
GuardBench has a public leaderboard available on HuggingFace.
You can find the list of supported datasets here. A few of them requires authorization. Please, read this.
If you use GuardBench to evaluate guardrail models for your scientific publications, please consider citing our work.
python>=3.10
pip install guardbench
from guardbench import benchmark
def moderate(
conversations: list[list[dict[str, str]]], # MANDATORY!
# additional `kwargs` as needed
) -> list[float]:
# do moderation
# return list of floats (unsafe probabilities)
benchmark(
moderate=moderate, # User-defined moderation function
model_name="My Guardrail Model",
batch_size=1, # Default value
datasets="all", # Default value
metrics=["f1", "recall"], # Default value
# Note: you can pass additional `kwargs` for `moderate`
)
Llama Guard with GuardBench.scripts folder.Browse the documentation for more details about:
GuardBench.Report class to compare models and export results as LaTeX tables.GuardBench's benchmarking pipeline on custom datasets.You can find GuardBench's leaderboard here. If you want to submit your results, please contact us.
@inproceedings{guardbench,
title = "{G}uard{B}ench: A Large-Scale Benchmark for Guardrail Models",
author = "Bassani, Elias and
Sanchez, Ignacio",
editor = "Al-Onaizan, Yaser and
Bansal, Mohit and
Chen, Yun-Nung",
booktitle = "Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing",
month = nov,
year = "2024",
address = "Miami, Florida, USA",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2024.emnlp-main.1022",
doi = "10.18653/v1/2024.emnlp-main.1022",
pages = "18393--18409",
}
Would you like to see other features implemented? Please, open a feature request.
GuardBench is provided as open-source software licensed under EUPL v1.2.
69 followers · starred Feb 2025
precision (Precision), recall (Recall), f1 (F1), mcc (Matthews Correlation Coefficient), auprc (AUPRC), sensitivity (Sensitivity), specificity (Specificity), g_mean (G-Mean), fpr (False Positive Rate), fnr (False Negative Rate).GuardBench is a Python library for the evaluation of guardrail models, i.e., LLMs fine-tuned to detect unsafe content in human-AI interactions.
GuardBench provides a common interface to 40 evaluation datasets, which are downloaded and converted into a standardized format for improved usability.
It also allows to quickly compare results and export LaTeX tables for scientific publications.
GuardBench's benchmarking pipeline can also be leveraged on custom datasets.
GuardBench was featured in EMNLP 2024.
The related paper is available here.
GuardBench has a public leaderboard available on HuggingFace.
You can find the list of supported datasets here. A few of them requires authorization. Please, read this.
If you use GuardBench to evaluate guardrail models for your scientific publications, please consider citing our work.
python>=3.10
pip install guardbench
from guardbench import benchmark
def moderate(
conversations: list[list[dict[str, str]]], # MANDATORY!
# additional `kwargs` as needed
) -> list[float]:
# do moderation
# return list of floats (unsafe probabilities)
benchmark(
moderate=moderate, # User-defined moderation function
model_name="My Guardrail Model",
batch_size=1, # Default value
datasets="all", # Default value
metrics=["f1", "recall"], # Default value
# Note: you can pass additional `kwargs` for `moderate`
)
Llama Guard with GuardBench.scripts folder.Browse the documentation for more details about:
GuardBench.Report class to compare models and export results as LaTeX tables.GuardBench's benchmarking pipeline on custom datasets.You can find GuardBench's leaderboard here. If you want to submit your results, please contact us.
@inproceedings{guardbench,
title = "{G}uard{B}ench: A Large-Scale Benchmark for Guardrail Models",
author = "Bassani, Elias and
Sanchez, Ignacio",
editor = "Al-Onaizan, Yaser and
Bansal, Mohit and
Chen, Yun-Nung",
booktitle = "Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing",
month = nov,
year = "2024",
address = "Miami, Florida, USA",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2024.emnlp-main.1022",
doi = "10.18653/v1/2024.emnlp-main.1022",
pages = "18393--18409",
}
Would you like to see other features implemented? Please, open a feature request.
GuardBench is provided as open-source software licensed under EUPL v1.2.
69 followers · starred Feb 2025