Guardrails
Guardrails help you remove or replace specific patterns in input, output, or both during inference. Use guardrails to ensure your deployments handle sensitive or unwanted data consistently.
Create a guardrail
To create a guardrail:
- In your Workspace, go to the Guardrail page.
- Click + Create.
- Enter a unique name for the guardrail.
- Provide a regular expression (regex) pattern. You can use a standard or custom pattern.
- Enter a replacement string, the default "****" is prefilled.
- Choose whether to apply the guardrail to input, output, or both
- Click Save.
Use a guardrail in a Deployment
You can apply guardrails when you create a new Deployment or update an existing one:
- During Deployment creation, select the guardrails you want to use in the Deployment details step.
- To update guardrails for an existing Deployment, go to the update details page and select the desired guardrails under safety section.
You can apply multiple guardrails at the same time.
View guardrail usage in prediction logs
You can see which guardrails were applied to input and output in the prediction logs. This helps you track how guardrails affect your data during inference.
Prediction logs show the original request and response from the model, before any guardrails are applied. However, when you use an input guardrail, the model receives the validated (guardrail-processed) input. If you use an output guardrail, the response returned to you is also the validated output.
When your model has both input and output guardrails, be aware that the model works with the guardrail-processed input, not the original input. If the model's response includes portions of the input text, it will contain the already-filtered version. This happens because the model never sees the original unfiltered input.
In case of a batch request, the applied guardrails shown are the ones that have been applied anywhere in the batch.