-
Notifications
You must be signed in to change notification settings - Fork 881
FEAT: add MLCommons AILuminate v1.0 DEMO Prompt Set #828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Roman Lutz (romanlutz)
merged 6 commits into
microsoft:main
from
paulinek13:feat/770/add_mlcommons_ailuminatedataset
Mar 26, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d03bdf3
feat: add MLCommons AILuminate dataset
paulinek13 337608f
docstring update
paulinek13 7b94dac
renaming
paulinek13 770a97f
add hazard categories mapping
paulinek13 16dfc75
add a note
paulinek13 c621deb
tiny fix in the docstring
paulinek13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| from pathlib import Path | ||
| from typing import Literal, Optional | ||
|
|
||
| from pyrit.datasets.dataset_helper import fetch_examples | ||
| from pyrit.models import SeedPromptDataset | ||
| from pyrit.models.seed_prompt import SeedPrompt | ||
|
|
||
| # https://github.com/mlcommons/ailuminate#hazard-categories-and-abbreviations | ||
| _hazard_categories_map = { | ||
| "vcr": "Violent Crimes", | ||
| "src": "Sex-Related Crimes", | ||
| "cse": "Child Sexual Exploitation", | ||
| "ssh": "Suicide & Self-Harm", | ||
| "iwp": "Indiscriminate Weapons (CBRNE)", | ||
| "ipv": "Intellectual Property Violations", | ||
| "dfm": "Defamation", | ||
| "ncr": "Non-Violent Crimes", | ||
| "hte": "Hate", | ||
| "prv": "Privacy Violations", | ||
| "spc_ele": "Specialized Advice; elections", | ||
| "spc_fin": "Specialized Advice; financial", | ||
| "spc_hlt": "Specialized Advice; health", | ||
| "sxc_prn": "Sexual Content; pornographic", | ||
| "spc_lgl": "Specialized Advice; legal", | ||
| } | ||
|
|
||
|
|
||
| def fetch_mlcommons_ailuminate_demo_dataset( | ||
| source: str = ( | ||
| "https://raw.githubusercontent.com/mlcommons/ailuminate/refs/heads/main/" | ||
| "airr_official_1.0_demo_en_us_prompt_set_release.csv" | ||
| ), | ||
| source_type: Literal["public_url"] = "public_url", | ||
| cache: bool = True, | ||
| data_home: Optional[Path] = None, | ||
| ) -> SeedPromptDataset: | ||
| """ | ||
| Fetch examples from AILuminate v1.0 DEMO Prompt Set and create a SeedPromptDataset. | ||
|
|
||
| Returns: | ||
| SeedPromptDataset: A SeedPromptDataset containing the examples. | ||
|
|
||
| Note: | ||
| For more information about the dataset and related materials, visit: \n | ||
| - https://github.com/mlcommons/ailuminate \n | ||
| - https://mlcommons.org/ailuminate/ \n | ||
| - https://doi.org/10.48550/arXiv.2404.12241 | ||
| """ | ||
| examples = fetch_examples(source, source_type, cache, data_home) | ||
|
|
||
| seed_prompts = [ | ||
| SeedPrompt( | ||
| value=example["prompt_text"], | ||
| data_type="text", | ||
| name="", | ||
| dataset_name="AILuminate v1.0 DEMO Prompt Set", | ||
| # Saving both the full hazard category name and the abbreviation | ||
| harm_categories=[_hazard_categories_map[example["hazard"]], example["hazard"]], | ||
| description=( | ||
| "This dataset contains the DEMO prompt library of the AILuminate 1.0 prompt dataset, created by" | ||
| " MLCommons AI Risk & Reliability working group. It contains 1,200 human-generated prompts that" | ||
| " cover 12 different hazard categories. The dataset is a mix of adversarial and non-adversarial" | ||
| " prompts. This dataset is a 10% subset of the full AILuminate training dataset." | ||
| ), | ||
| source="https://github.com/mlcommons/ailuminate", | ||
| ) | ||
| for example in examples | ||
| ] | ||
|
|
||
| seed_prompt_dataset = SeedPromptDataset(prompts=seed_prompts) | ||
| return seed_prompt_dataset | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.