-
Notifications
You must be signed in to change notification settings - Fork 776
FEAT adding transphobia awareness dataset #989
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
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d12ca71
integrating transphobia awareness dataset
vb-creator 72ecedf
Updates: based on PR review
vb-creator 310a072
Merge branch 'main' into main
varshini2305 b279b76
rm unit test with fetch - for transphobia dataset
vb-creator dfbe6e7
Merge branch 'main' into main
varshini2305 6b300a6
comma separated author names
vb-creator c1d6244
Merge branch 'main' into main
romanlutz d4b8d09
removing long comments, and word wrapping to keep <120 chars
vb-creator 4fd4fcb
minor refactors to clean up and format
vb-creator 2d83daa
Merge branch 'main' into main
varshini2305 6ae71d4
rm fn args - fetch_transphobia_awareness_dataset
vb-creator 2d44eec
fix keyword err
vb-creator a8b4c2e
rm Optional
vb-creator 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| from typing import List | ||
|
|
||
| import pandas as pd | ||
|
|
||
| from pyrit.models import SeedPromptDataset | ||
| from pyrit.models.seed_prompt import SeedPrompt | ||
|
|
||
| # URLs for the datasets | ||
| RATINGS_URL = "https://zenodo.org/records/15482694/files/Ratings.xlsx?download=1" | ||
| QUESTION_RESPONSE_PAIRS_URL = "https://zenodo.org/records/15482694/files/Question_Response_Pairs.xlsx?download=1" | ||
| QUORA_QUESTION_LIST_URL = "https://zenodo.org/records/15482694/files/Quora%20Question%20List.xlsx?download=1" | ||
|
|
||
|
|
||
| def fetch_transphobia_awareness_dataset() -> SeedPromptDataset: | ||
| """ | ||
| Load the Transphobia-Awareness Dataset from web URLs and return as a SeedPromptDataset. | ||
|
|
||
| This function fetches and parses the transphobia awareness dataset, which contains | ||
| user-generated queries related to transphobia with human annotations and model responses. | ||
|
|
||
| Transphobia dataset is loaded from the source cited below. | ||
| Scheuerman, M., Weathington, K., Petterson, A., Doyle, D. T., Das, D., DeVito, M. A., & Brubaker, J. | ||
| (2025). Quora Questions and LLM Responses on Transgender and Non-Binary Topics [Data set]. | ||
| Zenodo. https://doi.org/10.5281/zenodo.15482694 | ||
|
|
||
| This dataset is detailed in the paper cited below. | ||
| Morgan Klaus Scheuerman, Katy Weathington, Adrian Petterson, | ||
| Dylan Doyle, Dipto Das, Michael Ann DeVito, Jed Brubaker. | ||
| "Transphobia is in the Eye of the Prompter: | ||
| Trans-Centered Perspectives on Large Language Models." | ||
| ACM Transactions on Computer-Human Interaction (2018). | ||
|
|
||
| Returns: | ||
| SeedPromptDataset: A dataset of prompts with transphobia awareness metadata. | ||
|
|
||
| Notes: | ||
| - ratings.xlsx is the main file, with human ratings and model responses. | ||
| - question_response_pairs.xlsx and quora question list.xlsx can be used to enrich metadata. | ||
| - All files are fetched from their URLs by default. | ||
| - Harm categories are populated from unique keyword values. | ||
| """ | ||
| # Always fetch from URLs | ||
| ratings_df = pd.read_excel(RATINGS_URL, header=1) | ||
|
|
||
| seed_prompts: List[SeedPrompt] = [] | ||
|
|
||
| # Map keywords for consistency | ||
| ratings_df["keyword"] = ratings_df["keyword"].replace( | ||
| {"Trans": "transgender", "Transgender": "transgender", "nonbinary": "non-binary"} | ||
| ) | ||
| unique_keywords = ratings_df["keyword"].unique().tolist() | ||
| harm_categories = ["transphobia"] + unique_keywords | ||
|
romanlutz marked this conversation as resolved.
|
||
|
|
||
| for _, row in ratings_df.iterrows(): | ||
| metadata = { | ||
| "keyword": row["keyword"], | ||
| "question_sentiment": row.get( | ||
| """Question sentiment: How transphobic is the question?\n\nRate on a scale of 1-6, | ||
| where 6 is the most transphobic""" | ||
| ), | ||
| } | ||
|
|
||
| prompt = SeedPrompt( | ||
| value=row["Quora Question"], | ||
| data_type="text", | ||
| dataset_name="Transphobia-Awareness", | ||
| harm_categories=["transphobia"], | ||
| description="Quora-style question for transphobia awareness and inclusivity evaluation.", | ||
| metadata=metadata, | ||
| source=RATINGS_URL, | ||
| authors=[ | ||
| "Morgan Klaus Scheuerman", | ||
| "Katy Weathington", | ||
| "Adrian Petterson", | ||
| "Dylan Thomas Doyle", | ||
| "Dipto Das", | ||
| "Michael Ann DeVito", | ||
| "Jed R. Brubaker", | ||
| ], | ||
| ) | ||
| seed_prompts.append(prompt) | ||
|
|
||
| return SeedPromptDataset( | ||
| prompts=seed_prompts, | ||
| name="Transphobia-Awareness", | ||
| dataset_name="Transphobia-Awareness", | ||
| harm_categories=harm_categories, | ||
| description="Dataset for evaluating LLM responses for transphobia and inclusivity.", | ||
| source=RATINGS_URL, | ||
| ) | ||
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.