Skip to content

Conversation

@riyosha
Copy link
Contributor

@riyosha riyosha commented Jan 7, 2026

Description

Added VLSU multimodal dataset. This dataset contains multimodal prompts (text+images) which have safety gradings and categories for the text, images and both combined. This functionality creates text prompts, image prompts and multimodal prompts from the same.

Closes #1285.

Files Changed:

pyrit/datasets/seed_datasets/remote/vlsu_multimodal_dataset.py (new)
pyrit/datasets/seed_datasets/remote/__init__.py (updated exports)
pyrit/datasets/__init__.py (updated exports)
tests/unit/datasets/test_vlsu_multimodal_dataset.py (new)
pyrit/models/seed.py (added optional prompt_text option in the image prompt)

Features:

  • Loads image-text pairs from the official ML-VLSU repository
  • Creates prompts based on safety grades:
    -- Text-only prompts: When text_grade is unsafe/borderline
    -- Image-only prompts: When image_grade is unsafe/borderline
    -- Combined prompts: When combined_grade is unsafe/borderline (captures emergent harm)
  • Supports filtering by 15 harm categories (e.g., hate speech, discrimination, violence)
  • Configurable unsafe_grades parameter to control which grades trigger prompt creation (options are safe, unsafe, borderline, not_sure)
  • Supports random sampling with configurable limit and seed (for quicker testing. I can remove this if undesirable)
  • Caches downloaded images locally for faster subsequent loads

Tests and Documentation

  • Some essential unit tests added intests/unit/datasets/test_vlsu_multimodal_dataset.py
    -- Test dataset name property
    -- Test initialization with categories
    -- Test invalid categories raise ValueError
    -- Test text-only prompt creation (unsafe text grade)
    -- Test image-only prompt creation (unsafe image grade)
    -- Test combined prompt creation (unsafe combined grade)
    -- Test all prompts created when all grades unsafe
    -- Test borderline grades trigger prompt creation
    -- Test no prompts when all grades safe (expects error)
    -- Test category filtering
    -- Test handling of failed image downloads

  • pre-commit run --all-files passes

group_id = uuid.uuid4()

# Create text prompt if text_grade is unsafe or borderline
if text_grade in self.unsafe_grades:
Copy link
Contributor

@rlundeen2 rlundeen2 Jan 10, 2026

Choose a reason for hiding this comment

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

If I understand this dataset correctly, each line in the dataset has both a text part and an image part. So I would just say if the harm is sufficient, make sure both have the same group id and add them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The text and image parts individually might have a different safety grade than the combined prompt - for instance, text and image individually might be harmful individually, but their combined prompt can be a safe prompt. I thought it could be useful to create individual text and image prompts to use them in cases where the combined prompt would be skipped.

I could create the unsafe text/image prompts specifically when the combined prompt is safe and they'd be skipped otherwise. Or if you think its better to remove them completely, I can just keep the combined prompts too

Copy link
Contributor

Choose a reason for hiding this comment

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

I think they should always be added (or not) together, because we likely always want to send them together as part of a single Message.

I don't care quite as much about how we decide which ones to add as much as they be added together so we can handle them consistently :)

continue

# Handle UUID
if uuid_str:
Copy link
Contributor

Choose a reason for hiding this comment

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

We should always generate a new uuid. Otherwise there will be weirdness. It's unique to pyrit for when we pull these from the database

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right I overlooked that, makes sense!

@rlundeen2 rlundeen2 self-assigned this Jan 10, 2026
Copy link
Contributor

@rlundeen2 rlundeen2 left a comment

Choose a reason for hiding this comment

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

This is good! Thank you! I think once comments are addressed and CI passes it should be ready to merge.

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.

FEAT Add VLSU dataset

2 participants