For the complete documentation index, see llms.txt. This page is also available as Markdown.

ProtectAI

Binary prompt-injection classifiers.

Runs one of ProtectAI's encoder classifiers over a single user prompt and reports whether the text is a prompt-injection / jailbreak attempt. Each model is a two-class sequence classifier whose unsafe class is labeled "INJECTION"; the guardrail treats that class as the risky one. SUPPORTED_MODELS spans ProtectAI's LLM-security collection — three DeBERTa-v3 prompt-injection models (small, base v1, base v2) plus a DistilRoBERTa "rejection" detector — with deberta-v3-small-prompt-injection-v2 as the default.

Expected input: prompt-only text. validate(input_text) accepts a single string, or a list[str] to classify a batch in one call; there is no prompt+response or chat-message mode.

Verdict mapping onto GuardrailOutput:

  • valid is True when the predicted class is not "INJECTION" (i.e. the text looks safe).

  • score is the model's probability of the "INJECTION" class (canonical risk direction: higher = riskier).

  • categories carries one CategoryResult per class label, each with its softmax score and a triggered flag marking the argmax class.

  • No spans or modified_text are produced.

For more information, see:

Supported Models

  • ProtectAI/deberta-v3-small-prompt-injection-v2

  • ProtectAI/distilroberta-base-rejection-v1

  • ProtectAI/deberta-v3-base-prompt-injection

  • ProtectAI/deberta-v3-base-prompt-injection-v2

Constructor

Parameter
Type
Required
Default
Description

model_id

`str

None`

No

None

provider

Optional[Provider[dict[str, Any], dict[str, Any]]]

No

None

Execution backend that loads the model and runs inference. Defaults to a HuggingFaceProvider targeting AutoModelForSequenceClassification. Supply your own to control device, dtype, or cache_dir, or to run against a different backend.

Initialize the ProtectAI guardrail.

validate

Default validation pipeline: preprocess -> inference -> postprocess.

Parameters

Parameter
Type
Required
Default
Description

input_text

`str

list[str]`

Yes

—

Returns: GuardrailOutput | list[GuardrailOutput]

Benchmarks

Prompt Injection

Dataset (rev)
Metric
Threshold
Value
Harness
Source
Contam.

deepset_pi (unspecified)

f1

native-valid

0.536585

guardrail-bench+ag0.7.4

measured:guardrail-bench+ag0.7.4

notinject (unspecified)

fpr

native-valid

0.382456

guardrail-bench+ag0.7.4

measured:guardrail-bench+ag0.7.4

gandalf (unspecified)

recall

native-valid

1

guardrail-bench+ag0.7.4

measured:guardrail-bench+ag0.7.4

bipia_email (unspecified)

f1

native-valid

0.240976

bir@fd86c16

measured:bir@fd86c16

bipia_table (unspecified)

f1

native-valid

0.0168657

bir@fd86c16

measured:bir@fd86c16

License

  • Vendor: ProtectAI

  • Default license: apache-2.0 (of the default model/service)

Last updated