Jasper
Binary prompt-injection classifiers.
Runs one of JasperLS's encoder classifiers over a single user prompt and reports whether the text is a prompt-injection attempt. Each model is a two-class sequence classifier whose unsafe class is labeled "INJECTION"; the guardrail treats that class as the risky one. The default gelectra-base-injection is built on a German-language gELECTRA encoder, while deberta-v3-base-injection is built on an English DeBERTa-v3 encoder — pick the one that matches your prompt language.
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:
validisTruewhen the predicted class is not"INJECTION"(i.e. the text looks safe).scoreis the model's probability of the"INJECTION"class (canonical risk direction: higher = riskier).categoriescarries oneCategoryResultper class label, each with its softmaxscoreand atriggeredflag marking the argmax class.No
spansormodified_textare produced.
For more information, see:
gelectra-base-injection (default)
Raises: ValueError: If model_id is not in SUPPORTED_MODELS.
Supported Models
JasperLS/gelectra-base-injectionJasperLS/deberta-v3-base-injection
Constructor
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 Jasper guardrail.
validate
Default validation pipeline: preprocess -> inference -> postprocess.
Parameters
input_text
`str
list[str]`
Yes
—
Returns: GuardrailOutput | list[GuardrailOutput]
Benchmarks
Prompt Injection
deepset_pi (unspecified)
f1
native-valid
0.983051
guardrail-bench+ag0.7.4
measured:guardrail-bench+ag0.7.4
⚠️
notinject (unspecified)
fpr
native-valid
0.842105
guardrail-bench+ag0.7.4
measured:guardrail-bench+ag0.7.4
gandalf (unspecified)
recall
native-valid
0.919643
guardrail-bench+ag0.7.4
measured:guardrail-bench+ag0.7.4
bipia_email (unspecified)
f1
native-valid
0.776049
bir@fd86c16
measured:bir@fd86c16
bipia_table (unspecified)
f1
native-valid
0.873905
bir@fd86c16
measured:bir@fd86c16
License
Vendor: JasperLS
Default license:
mit(of the default model/service)
Last updated