Perform Inference with Guardrail
Perform inference with a Guardrail model, on a single input string or a list of input strings.
For each input string, this will return one of two predicted labels: safe
if the chatbot is allowed
to generate the input string or unsafe
if the chatbot is not allowed to generate the input string.
Arguments
- text str | list[str]
A string or a list of strings to classify. The model will return a label for each input string.
Response
A list[str]
, each being either "safe"
or "unsafe"
, which indicate whether the chatbot is
allowed to generate the input string or not.
- Python
from artifex import Artifex
guardrail = Artifex().guardrail
# NOTE: train your Guardrail model before
# using it for inference.
label = guardrail("This is a sample safe sentence.")
print(label)
- Response
["safe"]