guardbench


Nameguardbench JSON
Version 1.0.0 PyPI version JSON
download
home_pageNone
SummaryGuardBench: A Large-Scale Benchmark for Guardrail Models
upload_time2024-11-12 02:44:56
maintainerNone
docs_urlNone
authorElias Bassani
requires_python>=3.10
licenseNone
keywords harmful content detection harmful content toxic content detection toxic content guardrails guardrail models guardrail models evaluation guardrail models benchmark evaluation benchmark
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
  <!-- Python -->
  <a href="https://www.python.org" alt="Python"><img src="https://badges.aleen42.com/src/python.svg"></a>
  <!-- Version -->
  <a href="https://pypi.org/project/guardbench/"><img src="https://img.shields.io/pypi/v/guardbench?color=light-green" alt="PyPI version"></a>
  <!-- Docs -->
  <a href="https://github.com/AmenRa/guardbench/tree/main/docs"><img src="https://img.shields.io/badge/docs-passing-<COLOR>.svg" alt="Documentation Status"></a>
  <!-- Black -->
  <a href="https://github.com/psf/black" alt="Code style: black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
  <!-- License -->
  <a href="https://interoperable-europe.ec.europa.eu/sites/default/files/custom-page/attachment/2020-03/EUPL-1.2%20EN.txt"><img src="https://img.shields.io/badge/license-EUPL-blue.svg" alt="License: EUPL-1.2"></a>
</p>

# GuardBench

## ⚡️ Introduction
[`GuardBench`](https://github.com/AmenRa/guardbench) is a Python library for guardrail models evaluation.
It provides a common interface to 40 evaluation datasets, which are downloaded and converted into a [standardized format](data_format.md) for improved usability.
It also allows to quickly [compare results and export](docs/report.md) `LaTeX` tables for scientific publications.
[`GuardBench`](https://github.com/AmenRa/guardbench)'s benchmarking pipeline can also be leveraged on [custom datasets](docs/custom_dataset.md).

You can find the list of supported datasets [here](docs/datasets.md).
A few of them requires authorization. Please, see [here](docs/get_datasets.md).

If you use [`GuardBench`](https://github.com/AmenRa/guardbench) to evaluate guardrail models for your scientific publications, please consider [citing our work](#-citation).

## ✨ Features
- [40 datasets](docs/datasets.md) for guardrail models evaluation.
- Automated evaluation pipeline.
- User-friendly.
- [Extendable](docs/custom_dataset.md).
- Reproducible and sharable evaluation.
- Exportable [evaluation reports](docs/report.md).

## 🔌 Requirements
```bash
python>=3.10
```

## 💾 Installation 
```bash
pip install guardbench
```

## 💡 Usage
```python
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=32,
    datasets="all", 
    # Note: you can pass additional `kwargs` for `moderate`
)
```

### 📖 Examples
- Follow our [tutorial](docs/llama_guard.md) on benchmarking [`Llama Guard`](https://arxiv.org/pdf/2312.06674) with [`GuardBench`](https://github.com/AmenRa/guardbench).
- More examples are available in the [`scripts`](scripts/effectiveness) folder.

## 📚 Documentation
Browse the documentation for more details about:
- The [datasets](docs/datasets.md) and how to [obtain them](docs/get_datasets.md).
- The [data format](data_format.md) used by [`GuardBench`](https://github.com/AmenRa/guardbench).
- How to use the [`Report`](docs/report.md) class to compare models and export results as `LaTeX` tables.
- How to leverage [`GuardBench`](https://github.com/AmenRa/guardbench)'s benchmarking pipeline on [custom datasets](docs/custom_dataset.md).

## 🏆 Leaderboard
You can find [`GuardBench`](https://github.com/AmenRa/guardbench)'s leaderboard [here](docs/leaderboard.md).
All results can be reproduced using the provided [`scripts`](scripts/effectiveness).  
If you want to submit your results, please contact us.

## 👨‍💻 Authors
- Elias Bassani (European Commission - Joint Research Centre)

## 🎓 Citation
```bibtex
@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.pdf",
    pages = "18393--18409",
}
```

## 🎁 Feature Requests
Would you like to see other features implemented? Please, open a [feature request](https://github.com/AmenRa/guardbench/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=%5BFeature+Request%5D+title).

## 📄 License
[GuardBench](https://github.com/AmenRa/guardbench) is provided as open-source software licensed under [EUPL v1.2](https://github.com/AmenRa/guardbench/blob/master/LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "guardbench",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "harmful content detection, harmful content, toxic content detection, toxic content, guardrails, guardrail models, guardrail models evaluation, guardrail models benchmark, evaluation, benchmark",
    "author": "Elias Bassani",
    "author_email": "elias.bassani@ec.europa.eu",
    "download_url": "https://files.pythonhosted.org/packages/d9/cb/3c80b3da7bc96b4431f5e3553595184ac95b890a8a2222d42d5daac61861/guardbench-1.0.0.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n  <!-- Python -->\n  <a href=\"https://www.python.org\" alt=\"Python\"><img src=\"https://badges.aleen42.com/src/python.svg\"></a>\n  <!-- Version -->\n  <a href=\"https://pypi.org/project/guardbench/\"><img src=\"https://img.shields.io/pypi/v/guardbench?color=light-green\" alt=\"PyPI version\"></a>\n  <!-- Docs -->\n  <a href=\"https://github.com/AmenRa/guardbench/tree/main/docs\"><img src=\"https://img.shields.io/badge/docs-passing-<COLOR>.svg\" alt=\"Documentation Status\"></a>\n  <!-- Black -->\n  <a href=\"https://github.com/psf/black\" alt=\"Code style: black\"><img src=\"https://img.shields.io/badge/code%20style-black-000000.svg\"></a>\n  <!-- License -->\n  <a href=\"https://interoperable-europe.ec.europa.eu/sites/default/files/custom-page/attachment/2020-03/EUPL-1.2%20EN.txt\"><img src=\"https://img.shields.io/badge/license-EUPL-blue.svg\" alt=\"License: EUPL-1.2\"></a>\n</p>\n\n# GuardBench\n\n## \u26a1\ufe0f Introduction\n[`GuardBench`](https://github.com/AmenRa/guardbench) is a Python library for guardrail models evaluation.\nIt provides a common interface to 40 evaluation datasets, which are downloaded and converted into a [standardized format](data_format.md) for improved usability.\nIt also allows to quickly [compare results and export](docs/report.md) `LaTeX` tables for scientific publications.\n[`GuardBench`](https://github.com/AmenRa/guardbench)'s benchmarking pipeline can also be leveraged on [custom datasets](docs/custom_dataset.md).\n\nYou can find the list of supported datasets [here](docs/datasets.md).\nA few of them requires authorization. Please, see [here](docs/get_datasets.md).\n\nIf you use [`GuardBench`](https://github.com/AmenRa/guardbench) to evaluate guardrail models for your scientific publications, please consider [citing our work](#-citation).\n\n## \u2728 Features\n- [40 datasets](docs/datasets.md) for guardrail models evaluation.\n- Automated evaluation pipeline.\n- User-friendly.\n- [Extendable](docs/custom_dataset.md).\n- Reproducible and sharable evaluation.\n- Exportable [evaluation reports](docs/report.md).\n\n## \ud83d\udd0c Requirements\n```bash\npython>=3.10\n```\n\n## \ud83d\udcbe Installation \n```bash\npip install guardbench\n```\n\n## \ud83d\udca1 Usage\n```python\nfrom guardbench import benchmark\n\ndef moderate(\n    conversations: list[list[dict[str, str]]],  # MANDATORY!\n    # additional `kwargs` as needed\n) -> list[float]:\n    # do moderation\n    # return list of floats (unsafe probabilities)\n\nbenchmark(\n    moderate=moderate,  # User-defined moderation function\n    model_name=\"My Guardrail Model\",\n    batch_size=32,\n    datasets=\"all\", \n    # Note: you can pass additional `kwargs` for `moderate`\n)\n```\n\n### \ud83d\udcd6 Examples\n- Follow our [tutorial](docs/llama_guard.md) on benchmarking [`Llama Guard`](https://arxiv.org/pdf/2312.06674) with [`GuardBench`](https://github.com/AmenRa/guardbench).\n- More examples are available in the [`scripts`](scripts/effectiveness) folder.\n\n## \ud83d\udcda Documentation\nBrowse the documentation for more details about:\n- The [datasets](docs/datasets.md) and how to [obtain them](docs/get_datasets.md).\n- The [data format](data_format.md) used by [`GuardBench`](https://github.com/AmenRa/guardbench).\n- How to use the [`Report`](docs/report.md) class to compare models and export results as `LaTeX` tables.\n- How to leverage [`GuardBench`](https://github.com/AmenRa/guardbench)'s benchmarking pipeline on [custom datasets](docs/custom_dataset.md).\n\n## \ud83c\udfc6 Leaderboard\nYou can find [`GuardBench`](https://github.com/AmenRa/guardbench)'s leaderboard [here](docs/leaderboard.md).\nAll results can be reproduced using the provided [`scripts`](scripts/effectiveness).  \nIf you want to submit your results, please contact us.\n\n## \ud83d\udc68\u200d\ud83d\udcbb Authors\n- Elias Bassani (European Commission - Joint Research Centre)\n\n## \ud83c\udf93 Citation\n```bibtex\n@inproceedings{guardbench,\n    title = \"{G}uard{B}ench: A Large-Scale Benchmark for Guardrail Models\",\n    author = \"Bassani, Elias  and\n      Sanchez, Ignacio\",\n    editor = \"Al-Onaizan, Yaser  and\n      Bansal, Mohit  and\n      Chen, Yun-Nung\",\n    booktitle = \"Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing\",\n    month = nov,\n    year = \"2024\",\n    address = \"Miami, Florida, USA\",\n    publisher = \"Association for Computational Linguistics\",\n    url = \"https://aclanthology.org/2024.emnlp-main.1022.pdf\",\n    pages = \"18393--18409\",\n}\n```\n\n## \ud83c\udf81 Feature Requests\nWould you like to see other features implemented? Please, open a [feature request](https://github.com/AmenRa/guardbench/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=%5BFeature+Request%5D+title).\n\n## \ud83d\udcc4 License\n[GuardBench](https://github.com/AmenRa/guardbench) is provided as open-source software licensed under [EUPL v1.2](https://github.com/AmenRa/guardbench/blob/master/LICENSE).\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "GuardBench: A Large-Scale Benchmark for Guardrail Models",
    "version": "1.0.0",
    "project_urls": null,
    "split_keywords": [
        "harmful content detection",
        " harmful content",
        " toxic content detection",
        " toxic content",
        " guardrails",
        " guardrail models",
        " guardrail models evaluation",
        " guardrail models benchmark",
        " evaluation",
        " benchmark"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0c000f58e72e2222b7a0bd9f685d775816289a58fb9d8f0faee42ee82445dd3f",
                "md5": "8859c9ea381a61099e79cf091550029d",
                "sha256": "e98d6a1a367b37308035d70c0c728cfd4dc9564d67be1a785b4d18a9b70539ad"
            },
            "downloads": -1,
            "filename": "guardbench-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8859c9ea381a61099e79cf091550029d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 77510,
            "upload_time": "2024-11-12T02:44:54",
            "upload_time_iso_8601": "2024-11-12T02:44:54.982820Z",
            "url": "https://files.pythonhosted.org/packages/0c/00/0f58e72e2222b7a0bd9f685d775816289a58fb9d8f0faee42ee82445dd3f/guardbench-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d9cb3c80b3da7bc96b4431f5e3553595184ac95b890a8a2222d42d5daac61861",
                "md5": "06ad3ad1d421e64e79305cbdf53a9c69",
                "sha256": "9b775a8b1fc306342a1465d7f877492fe7e5def8833291a474cfeecb7dc443b7"
            },
            "downloads": -1,
            "filename": "guardbench-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "06ad3ad1d421e64e79305cbdf53a9c69",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 52191,
            "upload_time": "2024-11-12T02:44:56",
            "upload_time_iso_8601": "2024-11-12T02:44:56.102328Z",
            "url": "https://files.pythonhosted.org/packages/d9/cb/3c80b3da7bc96b4431f5e3553595184ac95b890a8a2222d42d5daac61861/guardbench-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-12 02:44:56",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "guardbench"
}
        
Elapsed time: 0.42699s