Repository navigation
[FEAT] Add SemGuard Arabic Security Dataset loader - #2468
Conversation
…Dataset loader for the SemGuard Arabic Security Dataset:807 validated Arabic/Arabizi/English prompt attack examples across7 threat categories, validated via a three-judge LLM-as-Judgepipeline (GPT-4o, Grok-4, Llama 3.3 70B; Fleiss' kappa = 0.839).Introduces SemGuardCategory enum for filtering by threat category.
…y-path fetch, category filtering, empty-after-filterraises, empty-text-skipped, dataset_name property, harm categoryalias overrides, and SemGuardCategory enum values.
…ed via: jupytext --to ipynb --execute
|
@microsoft-github-policy-service agree |
|
Hi Roman Lutz (Roman Lutz (@romanlutz)) — just following up on #2468 whenever you get a chance. It's ready for review (9 unit tests passing, notebook regenerated), though I noticed the CI checks are still pending maintainer approval to run, so let me know if there's anything needed on my end to move that along. |
… enum values via _validate_enums, let original exceptions propagate - SAFE is now opt-in via categories=[SemGuardCategory.SAFE], not loaded by default (default set is the six attack categories) - categories validated via self._validate_enums for immediate ValueError on invalid input - Removed generic Exception wrapper; ValueError, auth failures, and fetch errors now propagate with their original type - Added tests: safe excluded by default, safe included when requested, invalid category raises, propagated ValueError type - Regenerated notebook per review comment
|
hannahwestra25 Thanks for the thorough review , addressed all four points:
All 12 unit tests passing locally ( |
…lass-level harm_categories - text/category now use (item.get(k) or '').strip() since HF's CSV loader returns None for blank cells, not missing keys - injection_jailbreak now maps to HarmCategory.DECEPTION instead of COORDINATION_HARM (deceptive-inducement framing fits prompt injection better than coordination-of-harm) - Added class-level harm_categories = [c.value for c in SemGuardCategory], following the CoCoNot pattern, so dataset-level metadata isn't blank - Added test_fetch_dataset_skips_item_with_none_text and test_class_level_harm_categories_metadata
…ip-notebook-progress-bars, EOF, ruff-format)
|
hannahwestra25 Addressed all four points from your review:
All 14 unit tests passing locally. One unrelated note: the build-book version-matrix jobs (Build 0.12.1–1.1.0) are failing on git fetch ... releases/vX.Y.Z, which looks like a fork-specific issue (those release tags/branches don't exist on my fork) rather than anything in this PR flagging in case it's expected. Also noticed the latest build_and_test run is showing "Action required" , could you approve it whenever you get a chance? |
hannahwestra25
left a comment
There was a problem hiding this comment.
looks good! thanks so much for contributing!!
Description
Adds a
SeedDatasetloader for the SemGuard Arabic SecurityDataset — 807 validated Arabic/Arabizi/English prompt attack
examples across 7 threat categories (injection/jailbreak,
phishing, privacy leakage, violent incitement, harmful content,
impersonation, safe). Validated via a three-judge LLM-as-Judge
pipeline (GPT-4o, Grok-4, Llama 3.3 70B; Fleiss' kappa = 0.839).
Closes #2331.
Implementation notes, per the discussion in #2331:
SemGuardCategory(7 values) lets callersfilter by threat category, following the
VLGuardSubsetpattern.SAFEis included as an explicit filterable value rather thanalways loaded, per Roman Lutz (@romanlutz)'s point about excluding safe
prompts by default.
metadataincludes alanguagefield (ar,en, or code-switched), so users canfilter or at least identify non-English prompts programmatically
even without reading Arabic. Category-level docstrings and the
loader's own docstring describe each category in English. Open
to adding English glosses per-seed if that would help further.
HarmCategorytaxonomydoesn't have a direct entry for "prompt injection" as an attack
technique (as opposed to a content-harm type), so
injection_jailbreakmaps toCOORDINATION_HARMviaHARM_CATEGORY_ALIAS_OVERRIDES. Flagging this in case a moreprecise mapping is preferred.
loader file's MIT license, consistent with how gated/externally
licensed datasets like VLGuard are handled).
Paper: accepted at IEEE AEECT 2026 (citation added to
references.bib/bibliography.md).Tests and Documentation
tests/unit/datasets/test_semguard_dataset.py: 9 testscovering happy-path fetch, category filtering, empty-after-filter
raises
ValueError, empty-text rows are skipped,dataset_nameproperty,
HARM_CATEGORY_ALIAS_OVERRIDEScoverage for all 7categories, and
SemGuardCategoryenum values. All passinglocally (
pytest tests/unit/datasets/test_semguard_dataset.py -v→ 9 passed).
SemGuardCategoryinpyrit/datasets/seed_datasets/remote/__init__.py.abughallous2026semguard) todoc/references.biband the cite key todoc/bibliography.md.doc/code/datasets/1_loading_datasets.py(prose list)and regenerated the notebook via:
jupytext --to ipynb --execute doc/code/datasets/1_loading_datasets.py— ran clean, confirmed
semguardappears in the executedget_all_dataset_names_async()output cell alongside the otherbuilt-in datasets.