guardrail-dataset-engineering

Curates, deduplicates, and splits prompt injection datasets from Hugging Face for guardrail model training.

1|Updated Sep 1, 2026
One-click install
npx skills add https://github.com/nvtruongops/pi-guard --skill guardrail-dataset-engineering-nvtruongops
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guardrail-dataset-engineering
Source: https://github.com/nvtruongops/pi-guard/tree/main/.agents/skills/guardrail-dataset-engineering
Command: npx skills add https://github.com/nvtruongops/pi-guard --skill guardrail-dataset-engineering-nvtruongops

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires scikit-learn, datasets.

What problem does it solve? Building a training dataset for prompt injection and jailbreak detection is error-prone: paraphrased attack templates leak across train/test splits, benign classes are underrepresented, and obfuscated attacks like leetspeak or Base64 evade naive data collection. This Skill provides a structured methodology for assembling a leak-free, balanced dataset from public Hugging Face sources. ## Core Features & Use Cases - Attack Taxonomy: Defines nine labeled categories covering direct injection, indirect injection, jailbreaks, adversarial evasion, and benign hard negatives. - Group-Aware Splitting: Uses MD5 prefix clustering with scikit-learn GroupShuffleSplit to prevent paraphrase leakage between train, validation, and test sets. - Provenance Manifest: Generates a JSON manifest tracking dataset sources, sample counts, and split ratios for reproducibility. - Adversarial Augmentation: Provides mutation recipes for leetspeak, Base64 encoding, character spacing, and zero-width character injection. - Use Case: A research team training a DeBERTa-based prompt injection classifier uses this guide to merge six Hugging Face datasets, cluster DAN template variants, and produce a 70/15/15 split without inflated test metrics. ## Quick Start Ask the AI to download the listed Hugging Face prompt injection datasets, cluster them by prompt prefix, and generate a group-aware train/validation/test split with a provenance manifest.

Frequently Asked Questions about guardrail-dataset-engineering

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent data leakage when splitting prompt injection datasets?

Cluster paraphrased attack templates by hashing the first 35 characters of each prompt with MD5, then split using scikit-learn GroupShuffleSplit with the cluster ID as the group column. This keeps all variants of one template family in a single split.

What Hugging Face datasets exist for prompt injection detection?

Common sources include deepset/prompt-injections, jayavibhav/prompt-injection, xTRam1/safe-guard-prompt-injection, Lakera/gandalf_ignore_instructions, and TrustAIRLab/in-the-wild-jailbreak-prompts. Benign samples can be subsampled from Open-Orca/OpenOrca to balance the negative class.

How do I generate adversarial examples like leetspeak or Base64 attacks?

Apply synthetic mutators to existing attack prompts: substitute vowels with lookalike digits for leetspeak, wrap payloads in a Base64 decode preamble, insert spaces between characters, or embed zero-width Unicode characters like \u200B within attack tokens.

Why does random train/test splitting inflate prompt injection model metrics?

Jailbreak datasets contain many minor paraphrases of the same template, such as DAN 1.0 and DAN 2.0. Random splitting places near-duplicates in both train and test sets, letting the model memorize templates rather than generalize, which inflates measured accuracy.

What train validation test ratio should I use for guardrail datasets?

The recommended split is 70% train, 15% validation, and 15% test, applied in two stages with GroupShuffleSplit. First separate the test set, then split the remainder into train and validation while preserving group assignments.