Skip to content

BUG: ComicJailbreak max_examples counts goals that render nothing, so templates=["code"] with max_examples=10 fails #3589

Closed

Description

Describe the bug

_ComicJailbreakDataset (pyrit/datasets/seed_datasets/remote/comic_jailbreak_dataset.py) documents max_examples as the "maximum number of source goals to render", but _fetch_dataset_async counts every goal it looks at, including goals that have no text for any of the selected templates and so render nothing. In the dataset, 213 of the 300 goals have no Code text, 61 have no Instruction text and 59 have no Speech text, so the cap is used up by goals that produce no seeds:

  • templates=["code"], max_examples=10: none of the first 10 goals has Code text, so nothing is rendered and loading fails with SeedDataset cannot be empty.
  • templates=["instruction"], max_examples=10: only 2 goals are rendered.

The cap is also checked only after a goal has been rendered, so max_examples=0 (or a negative value) still renders one goal.

Steps/Code to Reproduce

import asyncio

from pyrit.datasets.seed_datasets.remote.comic_jailbreak_dataset import _ComicJailbreakDataset
from pyrit.models import SeedObjective
from pyrit.setup.initialization import IN_MEMORY, initialize_pyrit_async


async def main():
    await initialize_pyrit_async(memory_db_type=IN_MEMORY)
    for templates, max_examples in ((["code"], 10), (["instruction"], 10), (["article"], 0)):
        try:
            loader = _ComicJailbreakDataset(templates=templates, max_examples=max_examples)
            dataset = await loader.fetch_dataset_async(cache=False)
        except ValueError as e:
            print(f"templates={templates} max_examples={max_examples}: ValueError: {str(e).splitlines()[0]}")
            continue
        goals = {s.value for s in dataset.seeds if isinstance(s, SeedObjective)}
        print(f"templates={templates} max_examples={max_examples}: {len(goals)} goals")


asyncio.run(main())

Expected Results

max_examples goals are rendered for each template, and a cap below 1 is rejected:

templates=['code'] max_examples=10: 10 goals
templates=['instruction'] max_examples=10: 10 goals
templates=['article'] max_examples=0: ValueError: max_examples must be at least 1 or None, got 0

Actual Results

templates=['code'] max_examples=10: ValueError: 1 validation error for SeedDataset
templates=['instruction'] max_examples=10: 2 goals
templates=['article'] max_examples=0: 1 goals

The first error is SeedDataset cannot be empty.

Screenshots

N/A

Versions

  • OS: Windows 11
  • Python version: 3.11.9
  • PyRIT version: installed from main (6224d53) in editable mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions