Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions pyrit/datasets/seed_datasets/remote/vlguard_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from enum import Enum
from pathlib import Path

from huggingface_hub import hf_hub_download

from pyrit.common.path import DB_DATA_PATH
from pyrit.datasets.seed_datasets.remote.remote_dataset_loader import (
_RemoteDatasetLoader,
Expand Down Expand Up @@ -37,7 +39,14 @@ class VLGuardCategory(Enum):


class VLGuardSubcategory(Enum):
"""Subcategories in the VLGuard dataset, nested under the main categories."""
"""
Subcategories in the VLGuard dataset. Each subcategory belongs to a specific category.

privacy: personal data
risky behavior: professional advice, political, sexually explicit, violence
deception: disinformation
discrimination: sex, race, other
"""

PERSONAL_DATA = "personal data"
PROFESSIONAL_ADVICE = "professional advice"
Expand Down Expand Up @@ -263,8 +272,6 @@ async def _download_dataset_files_async(self, *, cache: bool = True) -> tuple[li
Returns:
tuple[list[dict], Path]: Tuple of (metadata list, image directory path).
"""
from huggingface_hub import hf_hub_download

cache_dir = DB_DATA_PATH / "seed-prompt-entries" / "vlguard"
cache_dir.mkdir(parents=True, exist_ok=True)

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/datasets/test_vlguard_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def mock_hf_download(*, repo_id, filename, repo_type, local_dir, token):

with (
patch("pyrit.datasets.seed_datasets.remote.vlguard_dataset.DB_DATA_PATH", tmp_path),
patch("huggingface_hub.hf_hub_download", side_effect=mock_hf_download),
patch("pyrit.datasets.seed_datasets.remote.vlguard_dataset.hf_hub_download", side_effect=mock_hf_download),
):
metadata, result_dir = await loader._download_dataset_files_async(cache=False)

Expand Down
Loading