zm1990s/security-model-eval

Simple Model Eval Script based on Deepset

9

stars

20

commits

Python

primary language

May 13, 2026

updated

README

Prompt Injection Evaluation Tool

A comprehensive evaluation tool for prompt injection detection models. This tool includes dataset merging capabilities and supports evaluation of multiple model types with unified CSV datasets.

Features

  • Dataset Management: Merge multiple format datasets (CSV, TSV, JSON, Parquet) into unified format, defaults to 20265 samples from various sources.
  • Short Dataset Creation: Create balanced smaller datasets for faster testing and development
  • Model Support: Multiple model types (Llama Prompt Guard, ProtectAI DeBERTa, PreambleAI, Qualifire, SavantAI, etc.)
  • Binary Classification: Standardized binary labels (0=Safe, 1=Threat) with original label preservation
  • Comprehensive Metrics: Detailed evaluation metrics including confusion matrix analysis
  • Organized Output: Results saved in structured directories under results/
  • Command Line Interface: Flexible CLI for evaluation with sampling support

Prerequisites

Environment Setup

conda create -n model-eval python=3.12
conda activate model-eval
python -m pip install torch pandas transformers tqdm pyarrow -i https://pypi.tuna.tsinghua.edu.cn/simple

Project Structure

prompt-injection-eval/
├── merge_datasets.py         # Dataset merging script
├── model-eval-v2.0.py       # Main evaluation script v2.0
├── model-eval-v1.1.py       # Legacy evaluation script
├── datasets/                # Dataset directory
│   ├── create_short_dataset.py  # Short dataset creation script
│   ├── dataset-source/      # Original datasets in various formats
│   │   ├── *.csv            # CSV datasets
│   │   ├── *.tsv            # TSV datasets
│   │   ├── *.json           # JSON datasets
│   │   └── *.parquet        # Parquet datasets
│   ├── merged_datasets.csv  # Unified merged dataset
│   └── merged_datasets_short_*.csv  # Balanced short datasets
├── models/                  # Model directory
│   ├── deepset-deberta/
│   ├── preambleai/
│   ├── qualifire/
│   └── protectaiv1/
│   └── protectaiv2/
└── results/                 # Evaluation results
    └── evaluation_results_*/

Quick Start

Step 1: Merge Datasets (Optional)

First, merge all datasets into a unified CSV format:

cd datasets
python merge_datasets.py

This will:

  • Scan datasets/dataset-source/ for all supported formats
  • Standardize column names and labels
  • Convert labels to binary format (0=Safe, 1=Threat)
  • Save unified dataset to datasets/merged_datasets.csv

Step 2: Evaluate Models

Run model evaluation using the merged dataset:

# Basic evaluation
# Default dataset: datasets/merged_datasets.csv, contains 20265 samples
# Default model: ./models/deepset-deberta/
python model-eval-v2.0.py --model ./models/deepset-deberta/

# With specific dataset (using short dataset for faster evaluation)
python model-eval-v2.0.py --model ./models/deepset-deberta/ --dataset datasets/merged_datasets_short_1000.csv

# Sample evaluation (1000 samples)
python model-eval-v2.0.py --model ./models/deepset-deberta/ --sample 1000

Model Evaluation Results Comparison

Evaluation Results on Full Dataset (20,265 samples)

Model NameAccuracyRecallPrecisionFPRF1 Score
Qualifire0.94570.90970.95430.02970.9315
Vijil mBERT0.93380.88580.94770.03340.9157
PreambleAI0.92590.84690.96640.02010.9027
SavantAI0.86460.89940.79420.15910.8435
ProtectAI v20.84530.72380.87320.07170.7915
Llama Prompt Guard0.79060.55520.88600.04870.6826
ProtectAI v10.70760.30230.92930.01570.4562
Deepset DeBERTa0.55570.98560.47700.73770.6429

Evaluation Results on 4,000 Sample Dataset

Model NameAccuracyRecallPrecisionFPRF1 Score
Aliyun AI Guardrails0.82480.75710.85190.11570.8017
Azure Prompt Shield0.66950.34570.86930.04570.4946
Qualifire0.90020.85200.92890.05730.8888
SavantAI0.84250.86320.81200.17570.8368
PreambleAI0.84070.73170.91020.06340.8113
Vijil mBERT0.83930.74350.89510.07660.8135
ProtectAI v20.81600.70340.87910.08500.7815
Llama Prompt Guard0.72280.48690.85940.07000.6216
ProtectAI v10.64950.30140.85580.04460.4458
Deepset DeBERTa0.63320.96040.56330.65430.7101

Evaluation Results on 3,000 Sample Dataset

Model NameAccuracyRecallPrecisionFPRF1 Score
Aliyun AI Guardrails0.80580.73230.84000.12720.7825
Azure Prompt Shield0.65720.34520.84440.05800.4901
Qualifire0.88400.83300.91620.06950.8726
SavantAI0.82770.84560.80350.18870.8240
PreambleAI0.82100.70860.89420.07650.7906
Vijil mBERT0.81600.70860.88250.08600.7860
ProtectAI v20.81230.71210.87090.09620.7835
Llama Prompt Guard0.70500.47240.83870.08290.6044
Deepset DeBERTa0.63800.95040.57260.64690.7147
ProtectAI v10.63800.30330.82980.05670.4442

Evaluation Results on 2,000 Sample Dataset

Model NameAccuracyRecallPrecisionFPRF1 Score
Aliyun AI Guardrails0.77470.68230.83230.13470.7499
Azure Prompt Shield0.62780.33200.80490.07960.4701
Qualifire0.84650.78670.89170.09440.8359
ProtectAI v20.80700.72540.86450.11230.7888
SavantAI0.80400.81190.79740.20380.8046
PreambleAI0.78800.67910.86540.10440.7610
Vijil mBERT0.77950.66400.86050.10640.7496
Llama Prompt Guard0.66300.42860.80080.10540.5583
Deepset DeBERTa0.64200.93060.58840.64310.7210
ProtectAI v10.60950.29680.78250.08150.4303

Evaluation Results on 1,000 Sample Dataset

Model NameAccuracyRecallPrecisionFPRF1 Score
Aliyun AI Guardrails0.74450.64800.78640.16500.7106
Azure Prompt Shield0.60460.33610.69070.14200.4521
Qualifire0.81400.78560.82290.15920.8038
SavantAI0.77300.81440.74250.26600.7768
ProtectAI v20.76600.69480.79670.16700.7423
PreambleAI0.74800.66190.78480.17090.7181
Vijil mBERT0.74100.65150.77830.17480.7093
Deepset DeBERTa0.64300.93200.58250.62910.7169
Llama Prompt Guard0.63600.43300.70230.17280.5357
ProtectAI v10.59700.33200.67080.15340.4441

Key Findings

Top Performers (Full Dataset - 20,265 samples):

  1. Qualifire - Best overall performance with 94.57% accuracy and excellent balance of metrics
  2. Vijil mBERT - Strong second with 93.38% accuracy and high precision
  3. PreambleAI - High precision (96.64%) with good overall performance

Consistency Across Dataset Sizes:

  • Qualifire consistently ranks #1 across all dataset sizes
  • SavantAI show strong performance on smaller datasets
  • ProtectAI v1 consistently shows low recall but high precision
  • Deepset DeBERTa has very high recall but poor precision (high false positive rate)

Trade-offs:

  • High Precision, Lower Recall: PreambleAI, Llama Prompt Guard, ProtectAI v1
  • High Recall, Lower Precision: Deepset DeBERTa
  • Balanced Performance: Qualifire, Vijil mBERT, SavantAI

Dataset Management

Supported Input Formats

  • CSV: Comma-separated values
  • TSV: Tab-separated values
  • JSON: JavaScript Object Notation
  • Parquet: Apache Parquet format

Available Datasets

The project includes one full merged dataset and three pre-generated short datasets with balanced distribution:

Dataset Overview

DatasetTarget SamplesActual SamplesSafe (0)Threat (1)
merged_datasets.csvFull20,49612,076 (58.9%)8,420 (41.1%)
merged_datasets_short_1000.csv1,0361,000515 (51.5%)485 (48.5%)
merged_datasets_short_2000.csv2,3402,0001,006 (50.3%)994 (49.7%)
merged_datasets_short_3000.csv3,8403,0001,569 (52.3%)1,431 (47.7%)

Source Distribution

Source Datasetmerged_datasets.csv1000.csv2000.csv3000.csv
Total Samples20,4961,0002,0003,000
qualifire_prompt-injections-benchmark_test5,000 (24.4%)116 (11.6%)260 (13.0%)427 (14.2%)
train-00000-of-000018,236 (40.2%)115 (11.5%)260 (13.0%)427 (14.2%)
test-00000-of-000012,060 (10.1%)115 (11.5%)260 (13.0%)426 (14.2%)
allenai_wildjailbreak-eval2,210 (10.8%)115 (11.5%)260 (13.0%)427 (14.2%)
jackhhao_jailbreak-classification-jailbreak_dataset_full1,998 (9.7%)115 (11.5%)260 (13.0%)427 (14.2%)
train-00000-of-00001-9564e8b05b4757ab546 (2.7%)115 (11.5%)260 (13.0%)426 (14.2%)
PurpleLlama_CybersecurityBenchmarks_prompt_injection251 (1.2%)115 (11.5%)245 (12.2%)245 (8.2%)
test-00000-of-00001-701d16158af87368116 (0.6%)115 (11.5%)116 (5.8%)116 (3.9%)
rubend18_ChatGPT-Jailbreak-Prompts79 (0.4%)79 (7.9%)79 (4.0%)79 (2.6%)

merged_datasets.csv actually has 20265 samples, 231 samples are duplicates and are removed.

Label Distribution by Source (merged_datasets.csv)

Source DatasetTotalSafe (0)Threat (1)Safe %Threat %
qualifire_prompt-injections-benchmark_test5,0003,0011,99960.0%40.0%
train-00000-of-000018,2365,7402,49669.7%30.3%
test-00000-of-000012,0601,41065068.4%31.6%
allenai_wildjailbreak-eval2,2102102,0009.5%90.5%
jackhhao_jailbreak-classification-jailbreak_dataset_full1,9981,33266666.7%33.3%
train-00000-of-00001-9564e8b05b4757ab54634320362.8%37.2%
PurpleLlama_CybersecurityBenchmarks_prompt_injection25102510.0%100.0%
test-00000-of-00001-701d16158af87368116566048.3%51.7%
rubend18_ChatGPT-Jailbreak-Prompts7974593.7%6.3%

Short Dataset Creation

The create_short_dataset.py script allows you to create balanced smaller datasets from the full merged dataset for faster testing and development:

Features

  • Balanced Sampling: Maintains proportional representation from each source dataset
  • Label Balance: Preserves label distribution within each source when possible
  • Configurable Size: Specify target number of samples
  • Reproducible: Uses random seed for consistent results
  • Auto-naming: Generates descriptive filenames based on actual sample count

Usage

cd datasets

# Basic usage - creates 1000 samples by default
python create_short_dataset.py

# Custom sample size

python create_short_dataset.py --samples=1036
#python create_short_dataset.py --samples=2340
#python create_short_dataset.py --samples=3840


# Specify input and output files
python create_short_dataset.py --input merged_datasets.csv --output my_dataset.csv --samples 500

# With custom random seed
python create_short_dataset.py --samples 1000 --seed 123

Command Line Options

OptionDescriptionDefault
--inputInput CSV file pathmerged_datasets.csv
--outputOutput CSV file path (auto-generated if not specified)Auto-generated
--samplesTarget number of samples to extract1000
--seedRandom seed for reproducibility42

Example Output

Creating balanced short dataset with target of 1000 samples...
Loading dataset from: merged_datasets.csv
Loaded dataset with 20265 rows

=== Original Dataset Distribution ===
Label distribution:
  0 (Safe): 11,847 (58.4%)
  1 (Threat): 8,418 (41.6%)

=== Sampling Strategy ===
Target samples: 1000
Total sources: 9
Base samples per source: 111
Remainder to distribute: 1

Final short dataset saved to: merged_datasets_short_1000.csv

Dataset Structure

All datasets follow the same structure after merging:

ColumnDescriptionType
textThe prompt/text contentstring
labelBinary label (0=Safe, 1=Threat)integer
sourceSource dataset identifierstring
original_labelOriginal label from sourcestring

Label Mapping

The merging process standardizes all labels to binary format:

  • 0 (Safe): Normal, benign prompts
  • 1 (Threat): Prompt injection attempts, jailbreaks, malicious prompts

Model Configuration

Supported Models

  • Llama Prompt Guard 2 (86M): ./models/Llama-Prompt-Guard-2-86M/
  • ProtectAI DeBERTa v3: ./models/protectaiv2/
  • ProtectAI DeBERTa v1: ./models/protectaiv1/
  • PreambleAI: ./models/preambleai/
  • Qualifire: ./models/qualifire/
  • SavantAI: ./models/testsavantai-prompt-injection-defender-large-v0/
  • Deepset DeBERTa: ./models/deepset-deberta/
  • Vijil mBERT: ./models/vijil-mbert-prompt-injection/
  • YOUR OWN MODEL ...

Model Downloads

# Example model downloads using huggingface-cli
huggingface-cli download PreambleAI/prompt-injection-defense --local-dir ./models/preambleai/
huggingface-cli download protectai/deberta-v3-base-prompt-injection-v2 --local-dir ./models/protectaiv2/

Output Files

Results are saved in timestamped directories under results/:

results/evaluation_results_{model_name}_{timestamp}/
├── eval_results_{timestamp}.json      # Detailed results with predictions
├── eval_summary_{timestamp}.csv       # Flattened results for analysis
├── evaluation_report_{timestamp}.txt  # Human-readable report
└── evaluation_metrics_{timestamp}.json # Structured metrics

Evaluation Metrics

The tool provides comprehensive evaluation metrics:

  • Accuracy: Overall classification accuracy
  • Precision: Threat detection precision
  • Recall: Threat detection recall (sensitivity)
  • F1 Score: Harmonic mean of precision and recall
  • False Positive Rate (FPR): Rate of false threat detection
  • Confusion Matrix: Detailed classification breakdown

Advanced Usage

Custom Model Integration

To add your own model, create a directory under models/ and ensure it follows the HuggingFace transformers format.

Batch Evaluation

# Evaluate multiple models with the same dataset
 for model in deepset-deberta testsavantai-prompt-injection-defender-large-v0 Llama-Prompt-Guard-2-86M protectaiv1 protectaiv2 preambleai qualifire; do
    python model-eval-v2.0.py --model ./models/$model/ --dataset datasets/merged_datasets_short_2000.csv
done

Sampling Strategies

# Random sampling from full dataset
python model-eval-v2.0.py --model ./models/deepset-deberta/ --sample 500

# Use pre-created balanced short dataset
python model-eval-v2.0.py --model ./models/deepset-deberta/ --dataset datasets/merged_datasets_short_1000.csv

Version History

  • v2.0: Enhanced evaluation pipeline with better output formatting
  • v1.1: Added sampling support and improved metrics
  • v1.0: Initial release with basic model evaluation

Model Sources

3.1 testsavantai/prompt-injection-defender-large-v0

https://huggingface.co/testsavantai/prompt-injection-defender-large-v0

3.2 Qualifire

https://huggingface.co/qualifire/prompt-injection-sentinel

3.3 ProtectAI deberta-v3-base-prompt-injection-v2

https://huggingface.co/protectai/deberta-v3-base-prompt-injection-v2

3.4 Meta Llama Prompt-Guard-86M

https://huggingface.co/meta-llama/Prompt-Guard-86M/tree/main

3.5 vijil/mbert-prompt-injection

https://huggingface.co/vijil/mbert-prompt-injection

3.6 PreambleAI/prompt-injection-defense

https://huggingface.co/PreambleAI/prompt-injection-defense/tree/main Training dataset not specified

Dataset Sources

4.1 Deepset

Qualifire used this dataset for training: https://huggingface.co/datasets/deepset/prompt-injections

Clone of this dataset used by testsavantai/prompt-injection-defender-large-v0: https://huggingface.co/datasets/JasperLS/prompt-injections

4.2 allenai/wildjailbreak

Qualifire used this dataset for training: https://huggingface.co/datasets/allenai/wildjailbreak

4.3 jackhhao/jailbreak-classification

ProtectAI and Qualifire used this dataset for training: https://huggingface.co/datasets/jackhhao/jailbreak-classification

4.4 qualifire/prompt-injections-benchmark

https://huggingface.co/datasets/qualifire/prompt-injections-benchmark

4.5 xTRam1/safe-guard-prompt-injection

https://huggingface.co/datasets/xTRam1/safe-guard-prompt-injection

4.6 rubend18/ChatGPT-Jailbreak-Prompts

ProtectAI and testsavantai/prompt-injection-defender-large-v0 used this dataset for training: https://huggingface.co/datasets/rubend18/ChatGPT-Jailbreak-Prompts

4.7 NVIDIA nvidia/Aegis-AI-Content-Safety-Dataset-2.0

Prisma AIRS used this dataset for training: https://huggingface.co/datasets/nvidia/Aegis-AI-Content-Safety-Dataset-2.0

4.8 Purple Llama CyberSecEval

Llama Prompt Guard used this dataset for training: https://github.com/meta-llama/PurpleLlama/tree/23156b70efb596831c02c6461fc42da1f75988ec/CybersecurityBenchmarks

License

This project is open source. Please check individual model licenses for their respective usage terms.

Contributors

zm1990s

20 commits

zm1990s/security-model-eval

Simple Model Eval Script based on Deepset

9

stars

20

commits

Python

primary language

May 13, 2026

updated

README

Prompt Injection Evaluation Tool

A comprehensive evaluation tool for prompt injection detection models. This tool includes dataset merging capabilities and supports evaluation of multiple model types with unified CSV datasets.

Features

  • Dataset Management: Merge multiple format datasets (CSV, TSV, JSON, Parquet) into unified format, defaults to 20265 samples from various sources.
  • Short Dataset Creation: Create balanced smaller datasets for faster testing and development
  • Model Support: Multiple model types (Llama Prompt Guard, ProtectAI DeBERTa, PreambleAI, Qualifire, SavantAI, etc.)
  • Binary Classification: Standardized binary labels (0=Safe, 1=Threat) with original label preservation
  • Comprehensive Metrics: Detailed evaluation metrics including confusion matrix analysis
  • Organized Output: Results saved in structured directories under results/
  • Command Line Interface: Flexible CLI for evaluation with sampling support

Prerequisites

Environment Setup

conda create -n model-eval python=3.12
conda activate model-eval
python -m pip install torch pandas transformers tqdm pyarrow -i https://pypi.tuna.tsinghua.edu.cn/simple

Project Structure

prompt-injection-eval/
├── merge_datasets.py         # Dataset merging script
├── model-eval-v2.0.py       # Main evaluation script v2.0
├── model-eval-v1.1.py       # Legacy evaluation script
├── datasets/                # Dataset directory
│   ├── create_short_dataset.py  # Short dataset creation script
│   ├── dataset-source/      # Original datasets in various formats
│   │   ├── *.csv            # CSV datasets
│   │   ├── *.tsv            # TSV datasets
│   │   ├── *.json           # JSON datasets
│   │   └── *.parquet        # Parquet datasets
│   ├── merged_datasets.csv  # Unified merged dataset
│   └── merged_datasets_short_*.csv  # Balanced short datasets
├── models/                  # Model directory
│   ├── deepset-deberta/
│   ├── preambleai/
│   ├── qualifire/
│   └── protectaiv1/
│   └── protectaiv2/
└── results/                 # Evaluation results
    └── evaluation_results_*/

Quick Start

Step 1: Merge Datasets (Optional)

First, merge all datasets into a unified CSV format:

cd datasets
python merge_datasets.py

This will:

  • Scan datasets/dataset-source/ for all supported formats
  • Standardize column names and labels
  • Convert labels to binary format (0=Safe, 1=Threat)
  • Save unified dataset to datasets/merged_datasets.csv

Step 2: Evaluate Models

Run model evaluation using the merged dataset:

# Basic evaluation
# Default dataset: datasets/merged_datasets.csv, contains 20265 samples
# Default model: ./models/deepset-deberta/
python model-eval-v2.0.py --model ./models/deepset-deberta/

# With specific dataset (using short dataset for faster evaluation)
python model-eval-v2.0.py --model ./models/deepset-deberta/ --dataset datasets/merged_datasets_short_1000.csv

# Sample evaluation (1000 samples)
python model-eval-v2.0.py --model ./models/deepset-deberta/ --sample 1000

Model Evaluation Results Comparison

Evaluation Results on Full Dataset (20,265 samples)

Model NameAccuracyRecallPrecisionFPRF1 Score
Qualifire0.94570.90970.95430.02970.9315
Vijil mBERT0.93380.88580.94770.03340.9157
PreambleAI0.92590.84690.96640.02010.9027
SavantAI0.86460.89940.79420.15910.8435
ProtectAI v20.84530.72380.87320.07170.7915
Llama Prompt Guard0.79060.55520.88600.04870.6826
ProtectAI v10.70760.30230.92930.01570.4562
Deepset DeBERTa0.55570.98560.47700.73770.6429

Evaluation Results on 4,000 Sample Dataset

Model NameAccuracyRecallPrecisionFPRF1 Score
Aliyun AI Guardrails0.82480.75710.85190.11570.8017
Azure Prompt Shield0.66950.34570.86930.04570.4946
Qualifire0.90020.85200.92890.05730.8888
SavantAI0.84250.86320.81200.17570.8368
PreambleAI0.84070.73170.91020.06340.8113
Vijil mBERT0.83930.74350.89510.07660.8135
ProtectAI v20.81600.70340.87910.08500.7815
Llama Prompt Guard0.72280.48690.85940.07000.6216
ProtectAI v10.64950.30140.85580.04460.4458
Deepset DeBERTa0.63320.96040.56330.65430.7101

Evaluation Results on 3,000 Sample Dataset

Model NameAccuracyRecallPrecisionFPRF1 Score
Aliyun AI Guardrails0.80580.73230.84000.12720.7825
Azure Prompt Shield0.65720.34520.84440.05800.4901
Qualifire0.88400.83300.91620.06950.8726
SavantAI0.82770.84560.80350.18870.8240
PreambleAI0.82100.70860.89420.07650.7906
Vijil mBERT0.81600.70860.88250.08600.7860
ProtectAI v20.81230.71210.87090.09620.7835
Llama Prompt Guard0.70500.47240.83870.08290.6044
Deepset DeBERTa0.63800.95040.57260.64690.7147
ProtectAI v10.63800.30330.82980.05670.4442

Evaluation Results on 2,000 Sample Dataset

Model NameAccuracyRecallPrecisionFPRF1 Score
Aliyun AI Guardrails0.77470.68230.83230.13470.7499
Azure Prompt Shield0.62780.33200.80490.07960.4701
Qualifire0.84650.78670.89170.09440.8359
ProtectAI v20.80700.72540.86450.11230.7888
SavantAI0.80400.81190.79740.20380.8046
PreambleAI0.78800.67910.86540.10440.7610
Vijil mBERT0.77950.66400.86050.10640.7496
Llama Prompt Guard0.66300.42860.80080.10540.5583
Deepset DeBERTa0.64200.93060.58840.64310.7210
ProtectAI v10.60950.29680.78250.08150.4303

Evaluation Results on 1,000 Sample Dataset

Model NameAccuracyRecallPrecisionFPRF1 Score
Aliyun AI Guardrails0.74450.64800.78640.16500.7106
Azure Prompt Shield0.60460.33610.69070.14200.4521
Qualifire0.81400.78560.82290.15920.8038
SavantAI0.77300.81440.74250.26600.7768
ProtectAI v20.76600.69480.79670.16700.7423
PreambleAI0.74800.66190.78480.17090.7181
Vijil mBERT0.74100.65150.77830.17480.7093
Deepset DeBERTa0.64300.93200.58250.62910.7169
Llama Prompt Guard0.63600.43300.70230.17280.5357
ProtectAI v10.59700.33200.67080.15340.4441

Key Findings

Top Performers (Full Dataset - 20,265 samples):

  1. Qualifire - Best overall performance with 94.57% accuracy and excellent balance of metrics
  2. Vijil mBERT - Strong second with 93.38% accuracy and high precision
  3. PreambleAI - High precision (96.64%) with good overall performance

Consistency Across Dataset Sizes:

  • Qualifire consistently ranks #1 across all dataset sizes
  • SavantAI show strong performance on smaller datasets
  • ProtectAI v1 consistently shows low recall but high precision
  • Deepset DeBERTa has very high recall but poor precision (high false positive rate)

Trade-offs:

  • High Precision, Lower Recall: PreambleAI, Llama Prompt Guard, ProtectAI v1
  • High Recall, Lower Precision: Deepset DeBERTa
  • Balanced Performance: Qualifire, Vijil mBERT, SavantAI

Dataset Management

Supported Input Formats

  • CSV: Comma-separated values
  • TSV: Tab-separated values
  • JSON: JavaScript Object Notation
  • Parquet: Apache Parquet format

Available Datasets

The project includes one full merged dataset and three pre-generated short datasets with balanced distribution:

Dataset Overview

DatasetTarget SamplesActual SamplesSafe (0)Threat (1)
merged_datasets.csvFull20,49612,076 (58.9%)8,420 (41.1%)
merged_datasets_short_1000.csv1,0361,000515 (51.5%)485 (48.5%)
merged_datasets_short_2000.csv2,3402,0001,006 (50.3%)994 (49.7%)
merged_datasets_short_3000.csv3,8403,0001,569 (52.3%)1,431 (47.7%)

Source Distribution

Source Datasetmerged_datasets.csv1000.csv2000.csv3000.csv
Total Samples20,4961,0002,0003,000
qualifire_prompt-injections-benchmark_test5,000 (24.4%)116 (11.6%)260 (13.0%)427 (14.2%)
train-00000-of-000018,236 (40.2%)115 (11.5%)260 (13.0%)427 (14.2%)
test-00000-of-000012,060 (10.1%)115 (11.5%)260 (13.0%)426 (14.2%)
allenai_wildjailbreak-eval2,210 (10.8%)115 (11.5%)260 (13.0%)427 (14.2%)
jackhhao_jailbreak-classification-jailbreak_dataset_full1,998 (9.7%)115 (11.5%)260 (13.0%)427 (14.2%)
train-00000-of-00001-9564e8b05b4757ab546 (2.7%)115 (11.5%)260 (13.0%)426 (14.2%)
PurpleLlama_CybersecurityBenchmarks_prompt_injection251 (1.2%)115 (11.5%)245 (12.2%)245 (8.2%)
test-00000-of-00001-701d16158af87368116 (0.6%)115 (11.5%)116 (5.8%)116 (3.9%)
rubend18_ChatGPT-Jailbreak-Prompts79 (0.4%)79 (7.9%)79 (4.0%)79 (2.6%)

merged_datasets.csv actually has 20265 samples, 231 samples are duplicates and are removed.

Label Distribution by Source (merged_datasets.csv)

Source DatasetTotalSafe (0)Threat (1)Safe %Threat %
qualifire_prompt-injections-benchmark_test5,0003,0011,99960.0%40.0%
train-00000-of-000018,2365,7402,49669.7%30.3%
test-00000-of-000012,0601,41065068.4%31.6%
allenai_wildjailbreak-eval2,2102102,0009.5%90.5%
jackhhao_jailbreak-classification-jailbreak_dataset_full1,9981,33266666.7%33.3%
train-00000-of-00001-9564e8b05b4757ab54634320362.8%37.2%
PurpleLlama_CybersecurityBenchmarks_prompt_injection25102510.0%100.0%
test-00000-of-00001-701d16158af87368116566048.3%51.7%
rubend18_ChatGPT-Jailbreak-Prompts7974593.7%6.3%

Short Dataset Creation

The create_short_dataset.py script allows you to create balanced smaller datasets from the full merged dataset for faster testing and development:

Features

  • Balanced Sampling: Maintains proportional representation from each source dataset
  • Label Balance: Preserves label distribution within each source when possible
  • Configurable Size: Specify target number of samples
  • Reproducible: Uses random seed for consistent results
  • Auto-naming: Generates descriptive filenames based on actual sample count

Usage

cd datasets

# Basic usage - creates 1000 samples by default
python create_short_dataset.py

# Custom sample size

python create_short_dataset.py --samples=1036
#python create_short_dataset.py --samples=2340
#python create_short_dataset.py --samples=3840


# Specify input and output files
python create_short_dataset.py --input merged_datasets.csv --output my_dataset.csv --samples 500

# With custom random seed
python create_short_dataset.py --samples 1000 --seed 123

Command Line Options

OptionDescriptionDefault
--inputInput CSV file pathmerged_datasets.csv
--outputOutput CSV file path (auto-generated if not specified)Auto-generated
--samplesTarget number of samples to extract1000
--seedRandom seed for reproducibility42

Example Output

Creating balanced short dataset with target of 1000 samples...
Loading dataset from: merged_datasets.csv
Loaded dataset with 20265 rows

=== Original Dataset Distribution ===
Label distribution:
  0 (Safe): 11,847 (58.4%)
  1 (Threat): 8,418 (41.6%)

=== Sampling Strategy ===
Target samples: 1000
Total sources: 9
Base samples per source: 111
Remainder to distribute: 1

Final short dataset saved to: merged_datasets_short_1000.csv

Dataset Structure

All datasets follow the same structure after merging:

ColumnDescriptionType
textThe prompt/text contentstring
labelBinary label (0=Safe, 1=Threat)integer
sourceSource dataset identifierstring
original_labelOriginal label from sourcestring

Label Mapping

The merging process standardizes all labels to binary format:

  • 0 (Safe): Normal, benign prompts
  • 1 (Threat): Prompt injection attempts, jailbreaks, malicious prompts

Model Configuration

Supported Models

  • Llama Prompt Guard 2 (86M): ./models/Llama-Prompt-Guard-2-86M/
  • ProtectAI DeBERTa v3: ./models/protectaiv2/
  • ProtectAI DeBERTa v1: ./models/protectaiv1/
  • PreambleAI: ./models/preambleai/
  • Qualifire: ./models/qualifire/
  • SavantAI: ./models/testsavantai-prompt-injection-defender-large-v0/
  • Deepset DeBERTa: ./models/deepset-deberta/
  • Vijil mBERT: ./models/vijil-mbert-prompt-injection/
  • YOUR OWN MODEL ...

Model Downloads

# Example model downloads using huggingface-cli
huggingface-cli download PreambleAI/prompt-injection-defense --local-dir ./models/preambleai/
huggingface-cli download protectai/deberta-v3-base-prompt-injection-v2 --local-dir ./models/protectaiv2/

Output Files

Results are saved in timestamped directories under results/:

results/evaluation_results_{model_name}_{timestamp}/
├── eval_results_{timestamp}.json      # Detailed results with predictions
├── eval_summary_{timestamp}.csv       # Flattened results for analysis
├── evaluation_report_{timestamp}.txt  # Human-readable report
└── evaluation_metrics_{timestamp}.json # Structured metrics

Evaluation Metrics

The tool provides comprehensive evaluation metrics:

  • Accuracy: Overall classification accuracy
  • Precision: Threat detection precision
  • Recall: Threat detection recall (sensitivity)
  • F1 Score: Harmonic mean of precision and recall
  • False Positive Rate (FPR): Rate of false threat detection
  • Confusion Matrix: Detailed classification breakdown

Advanced Usage

Custom Model Integration

To add your own model, create a directory under models/ and ensure it follows the HuggingFace transformers format.

Batch Evaluation

# Evaluate multiple models with the same dataset
 for model in deepset-deberta testsavantai-prompt-injection-defender-large-v0 Llama-Prompt-Guard-2-86M protectaiv1 protectaiv2 preambleai qualifire; do
    python model-eval-v2.0.py --model ./models/$model/ --dataset datasets/merged_datasets_short_2000.csv
done

Sampling Strategies

# Random sampling from full dataset
python model-eval-v2.0.py --model ./models/deepset-deberta/ --sample 500

# Use pre-created balanced short dataset
python model-eval-v2.0.py --model ./models/deepset-deberta/ --dataset datasets/merged_datasets_short_1000.csv

Version History

  • v2.0: Enhanced evaluation pipeline with better output formatting
  • v1.1: Added sampling support and improved metrics
  • v1.0: Initial release with basic model evaluation

Model Sources

3.1 testsavantai/prompt-injection-defender-large-v0

https://huggingface.co/testsavantai/prompt-injection-defender-large-v0

3.2 Qualifire

https://huggingface.co/qualifire/prompt-injection-sentinel

3.3 ProtectAI deberta-v3-base-prompt-injection-v2

https://huggingface.co/protectai/deberta-v3-base-prompt-injection-v2

3.4 Meta Llama Prompt-Guard-86M

https://huggingface.co/meta-llama/Prompt-Guard-86M/tree/main

3.5 vijil/mbert-prompt-injection

https://huggingface.co/vijil/mbert-prompt-injection

3.6 PreambleAI/prompt-injection-defense

https://huggingface.co/PreambleAI/prompt-injection-defense/tree/main Training dataset not specified

Dataset Sources

4.1 Deepset

Qualifire used this dataset for training: https://huggingface.co/datasets/deepset/prompt-injections

Clone of this dataset used by testsavantai/prompt-injection-defender-large-v0: https://huggingface.co/datasets/JasperLS/prompt-injections

4.2 allenai/wildjailbreak

Qualifire used this dataset for training: https://huggingface.co/datasets/allenai/wildjailbreak

4.3 jackhhao/jailbreak-classification

ProtectAI and Qualifire used this dataset for training: https://huggingface.co/datasets/jackhhao/jailbreak-classification

4.4 qualifire/prompt-injections-benchmark

https://huggingface.co/datasets/qualifire/prompt-injections-benchmark

4.5 xTRam1/safe-guard-prompt-injection

https://huggingface.co/datasets/xTRam1/safe-guard-prompt-injection

4.6 rubend18/ChatGPT-Jailbreak-Prompts

ProtectAI and testsavantai/prompt-injection-defender-large-v0 used this dataset for training: https://huggingface.co/datasets/rubend18/ChatGPT-Jailbreak-Prompts

4.7 NVIDIA nvidia/Aegis-AI-Content-Safety-Dataset-2.0

Prisma AIRS used this dataset for training: https://huggingface.co/datasets/nvidia/Aegis-AI-Content-Safety-Dataset-2.0

4.8 Purple Llama CyberSecEval

Llama Prompt Guard used this dataset for training: https://github.com/meta-llama/PurpleLlama/tree/23156b70efb596831c02c6461fc42da1f75988ec/CybersecurityBenchmarks

License

This project is open source. Please check individual model licenses for their respective usage terms.

Contributors

zm1990s

20 commits

Languages

Python

73.0%

HTML

23.6%

Shell

3.4%