Dataset released: prompt-injection-classification v1.0

#1
by SalutefaceAAC - opened

Prompt Injection Classification Dataset — v1.0 Released

Hi HuggingFace community!

I just published SalutefaceAAC/prompt-injection-classification, a synthetic dataset for training and evaluating prompt injection detection classifiers.

What's in it

  • 2,564 examples across train / validation / test splits (70/15/15)
  • Binary label: benign vs. injection
  • 7 fine-grained attack types with severity scores (0-3):
    • instruction_override — 'ignore previous instructions'
    • jailbreak — DAN, developer mode, unrestricted AI personas
    • prompt_leak — extracting system prompt / hidden instructions
    • role_play_override — named-persona jailbreaks (Alex, Shadow, FreeGPT...)
    • indirect_injection — injected into retrieved/supplied content (RAG attacks)
    • delimiter_abuse — special tokens / template tags to spoof boundaries
    • context_override — redefine model identity, simulation, sandbox claims

Why this matters

Prompt injection is OWASP LLM Top 10 #1. This dataset gives defenders a starting point for building classifiers, testing guardrails, and benchmarking detection systems without needing to curate adversarial examples by hand.

Formats

Both JSONL and Parquet available under data/. Apache 2.0 license.

Contributions, feedback, and issue reports welcome! If you train a model on this dataset, please share your results in this thread.


Generated with template-based synthesis + MD5 dedup. Part of the SalutefaceAAC OSS contribution series.

Connecting to the community discussion on prompt injection classifiers

There's an active Show & Tell thread on the HF forum:
"I trained a Prompt Injection Classifier Using a 14M Parameter Discriminator"

The thread is excellent — DeshwalX built a multi-label ELECTRA-small classifier with 90% micro F1. A thorough critique by John6666 identified three key gaps that this dataset was designed to address:


Gap 1: Ambiguous attack type definitions

The critic noted that the "adversarial" label is defined inconsistently across training sources. This dataset uses a concrete, mutually-exclusive taxonomy of 7 attack types:

attack_type What it covers
instruction_override Directives that try to replace or supersede the system prompt
context_override Manipulation of surrounding context to shift model behavior
delimiter_abuse Exploiting structural tokens (###, ---, XML tags) to inject
role_play_override Persona/character adoption to bypass safety ("you are DAN")
jailbreak Multi-step or metaphorical bypass framing
indirect_injection Injection via external content (retrieved docs, tool output)
prompt_leak Attempts to extract the system prompt or training data
none Benign prompts (negative class, ~10-15% of records)

Each record also carries a severity score (1–5) reflecting how likely the attack is to succeed against a naive model, which can be used for threshold calibration.


Gap 2: Insufficient contextual negatives

The critic flagged that false positives on quoted/translated injection text and benign prompts that look adversarial are a key weakness. The none class in this dataset includes prompts that:

  • Quote or reference prompt injection (meta-discussion)
  • Use imperative phrasing without being an actual injection
  • Include role-play that is benign (storytelling, persona assignment by the user for legitimate purposes)

Gap 3: No explanation field for understanding failure modes

Each record in this dataset includes an explanation field describing the attack mechanism in plain English. This is useful for:

  • Instruction-tuning a model to explain why a prompt is classified as injection (not just predict the label)
  • Debugging false positives by reading why borderline examples were labeled as they were

Usage

from datasets import load_dataset

ds = load_dataset("SalutefaceAAC/prompt-injection-classification")

# High-severity injection examples for hard-negative mining
hard_injections = ds["train"].filter(lambda x: x["label"] == "injection" and x["severity"] >= 4)

# Contextual negatives for calibration
negatives = ds["train"].filter(lambda x: x["attack_type"] == "none")

print(f"Hard injections: {len(hard_injections)}, Negatives: {len(negatives)}")

If you're building a classifier and find this dataset useful, would love to know which attack types your model struggles with most — that feedback will directly shape v2.0.

Sign up or log in to comment