Skip to content

FEAT Add HarmfulQA dataset loader#1421

Open
romanlutz wants to merge 1 commit intoAzure:mainfrom
romanlutz:romanlutz/add-harmful-qa-dataset
Open

FEAT Add HarmfulQA dataset loader#1421
romanlutz wants to merge 1 commit intoAzure:mainfrom
romanlutz:romanlutz/add-harmful-qa-dataset

Conversation

@romanlutz
Copy link
Contributor

Add remote dataset loader for HarmfulQA (declare-lab/HarmfulQA), containing ~2k harmful questions organized by academic topic and subtopic for testing LLM susceptibility to harm-inducing question-answering.

Copilot AI review requested due to automatic review settings March 1, 2026 14:14
@romanlutz romanlutz force-pushed the romanlutz/add-harmful-qa-dataset branch from f8de803 to e996238 Compare March 1, 2026 14:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new remote seed-dataset provider for the HuggingFace declare-lab/HarmfulQA dataset so it can be fetched and used as SeedPrompt entries within PyRIT’s dataset discovery/registration system.

Changes:

  • Introduced _HarmfulQADataset remote loader that fetches HarmfulQA from HuggingFace and converts rows into SeedPrompts.
  • Exported the new loader from pyrit.datasets.seed_datasets.remote to trigger auto-registration.
  • Added unit tests validating basic fetch + conversion behavior and dataset_name.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
pyrit/datasets/seed_datasets/remote/harmful_qa_dataset.py New remote dataset loader implementation for HarmfulQA -> SeedDataset/SeedPrompt conversion.
pyrit/datasets/seed_datasets/remote/init.py Re-export/import the new loader so it’s discoverable/registered alongside other remote loaders.
tests/unit/datasets/test_harmful_qa_dataset.py Unit tests for fetching/conversion and dataset_name behavior.

Comment on lines +76 to +80
dataset_name=self.dataset_name,
harm_categories=[item["topic"]],
description=description,
source="https://huggingface.co/datasets/declare-lab/HarmfulQA",
authors=authors,
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source field is hard-coded to the declare-lab/HarmfulQA URL, but this loader exposes dataset_name as a constructor parameter (self.hf_dataset_name). If callers override dataset_name, the returned SeedPrompts will still claim the default source, which is misleading. Consider deriving source (and the HF URL) from self.hf_dataset_name, or accept an explicit source_url parameter.

Copilot uses AI. Check for mistakes.
source="https://huggingface.co/datasets/declare-lab/HarmfulQA",
authors=authors,
groups=["DeCLaRe Lab, Singapore University of Technology and Design"],
metadata={"subtopic": item.get("subtopic", "")},
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

groups=[item.get('subtopic', '')] will produce [''] when subtopic is missing/empty, which creates an empty-named group downstream. Use a conditional (e.g., [] when falsy) so groups is either a meaningful label or omitted.

Suggested change
metadata={"subtopic": item.get("subtopic", "")},
metadata=(
{"subtopic": item["subtopic"]}
if item.get("subtopic")
else {}
),

Copilot uses AI. Check for mistakes.
Add remote dataset loader for HarmfulQA (declare-lab/HarmfulQA), containing ~2k
harmful questions organized by academic topic and subtopic for testing LLM
susceptibility to harm-inducing question-answering.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@romanlutz romanlutz force-pushed the romanlutz/add-harmful-qa-dataset branch from e996238 to d441180 Compare March 1, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants