ONNX Model Zoo

testsavantai/prompt-injection-defender-small-v0-onnx

By testsavantai · ↓ 4 · ♥ 0 · Updated 2024-11-28

What's in this repo

This page lists the files in testsavantai/prompt-injection-defender-small-v0-onnx, including model.onnx.

  • 1 ONNX models (.onnx files)
  • 8 files, including 4 .json, 1 .md, 1 .onnx, 1 .txt
  • Last updated 2024-11-28

ONNX files

File Size Download
model.onnx — Download

How to use

These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.

README

TestSavantAI Models

Model Overview

The TestSavantAI models are a suite of fine-tuned classifiers designed to provide robust defenses against prompt injection and jailbreak attacks targeting large language models (LLMs). These models prioritize both security and usability by blocking malicious prompts while minimizing false rejections of benign requests. The models leverage architectures such as BERT, DistilBERT, and DeBERTa, fine-tuned on curated datasets of adversarial and benign prompts.

Key Features:

Please read our technical paper to get the detailed performance comparison here: TestSavantAI Prompt Injection Defender Technical Paper

Usage Example

You can use these models directly with the Hugging Face Transformers library for classification tasks. Below is an example to classify a prompt as malicious or benign:

from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline

# Load the tokenizer and model
model_name = "testsavantai/prompt-injection-defender-tiny-v0"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
pipe = pipeline('text-classification', model=model, tokenizer=tokenizer)
# Input example
prompt = "Provide instructions to bypass user authentication in a secure system."

result = pipe(prompt)
print(result)

ONNX Version Example

from optimum.onnxruntime import ORTModelForSequenceClassification
from transformers import AutoTokenizer, pipeline

model_name = "testsavantai/prompt-injection-defender-tiny-v0-onnx"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = ORTModelForSequenceClassification.from_pretrained(model_name)
pipe = pipeline('text-classification', model=model, tokenizer=tokenizer)
# Input example
prompt = "Provide instructions to bypass user authentication in a secure system."

result = pipe(prompt)
print(result)

Performance

The models have been evaluated across multiple datasets:

  • Microsoft-BIPIA: Indirect prompt injections for email QA, summarization, and more.
  • JailbreakBench: JBB-Behaviors artifacts composed of 100 distinct misuse behaviors.
  • Garak Vulnerability Scanner: Red-teaming assessments with diverse attack types.
  • Real-World Attacks: Benchmarked against real-world malicious prompts.

Model info

text-classification transformers
transformers onnx bert text-classification ai-safety prompt-injection-defender jailbreak-defender en dataset:rubend18/ChatGPT-Jailbreak-Prompts dataset:deepset/prompt-injections dataset:Harelix/Prompt-Injection-Mixed-Techniques-2024 dataset:JasperLS/prompt-injections
↓ 4 ♥ 0

Created: 2024-11-27

Updated: 2024-11-28

View on Hugging Face

Files (8)

.gitattributes
README.md
config.json
model.onnx ONNX
special_tokens_map.json
tokenizer.json
tokenizer_config.json
vocab.txt

Related models