The problem
As a concept, guardrailing has a few areas that, when unoptimized, can introduce latency and be extremely resource-expensive. The main two areas are:- Guardrailing orchestration; and
- ML models that validate a single guard
The Guardrails approach
The Guardrails library tackles this problem by providing an interface that allows users to separate the execution of orchestration from the execution of ML-based validation. The layout of this solution is a simple upgrade to validator libraries themselves. Instead of always downloading and installing ML models, you can configure them to call a remote endpoint. This remote endpoint hosts the ML model behind an API that presents a unified interface for all validator models. Guardrails hosts some of these for free as a preview feature. Users can host their own models by following the same interface.Remote validation inferencing is only available in Guardrails versions 0.5.0 and above.
Using Guardrails inferencing endpoints
To use a guardrails endpoint, find a validator that has implemented support. Validators with a Guardrails-hosted endpoint are labeled as such on the Validator Hub. One example is Toxic Language.To use remote inferencing endpoints, you need a Guardrails API key. You can get one by signing up at the Guardrails Hub. Then, run
guardrails configure.Toggling remote inferencing
To enable/disable remote inferencing, you can run the CLI commandguardrails configure or modify your ~/.guardrailsrc.
use_local kwarg to the validator’s initializer.
When running locally, you may need to reinstall the validator with the
--install-local-models flag.Hosting your own endpoint
Validators can point to any endpoint that implements the interface that Guardrails validators expect. This interface can be found in the_inference_remote method of the validator.
After implementing this interface, you can host your own endpoint (for example, using gunicorn and Flask) and point your validator to it by setting the validation_endpoint constructor argument.
Contact us to host validators in your own VPC with managed hardware.