Skip to main content
Version: 1.50

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:

  1. In your Workspace, go to the Guardrail page.
  2. Click + Create.
  3. Enter a unique name for the guardrail.
  4. Provide a regular expression (regex) pattern. You can use a standard or custom pattern.
  5. Enter a replacement string, the default "****" is prefilled.
  6. Choose whether to apply the guardrail to input, output, or both
  7. 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.

note

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.

Beware

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.

note

In case of a batch request, the applied guardrails shown are the ones that have been applied anywhere in the batch.