guardrails-ai/guardrails
Adding guardrails to large language models.
What it solves
Guardrails is designed to make AI applications more reliable by preventing LLM outputs (and inputs) from containing risks or failing to follow a specific structure. It addresses the problem of unpredictable LLM behavior, such as toxic language, competitor mentions, or incorrectly formatted data, by providing a validation layer between the LLM and the application.
How it works
Guardrails uses a system of "validators"—pre-built measures of specific risks—that can be combined into "Guards." These Guards intercept the input or output of an LLM to detect, quantify, and mitigate risks. For structured data generation, it uses Pydantic models to define the desired output schema. It achieves this by either using the LLM's native function calling capabilities or by optimizing the prompt to ensure the LLM generates data that fits the schema.
Who it’s for
Developers building AI applications who need to ensure their LLM-powered features are consistent, safe, and produce structured, parseable data for downstream processing.
Highlights
- Guardrails Hub: A collection of pre-built validators for common risks like toxic language and competitor checks.
- Structured Data Generation: Uses Pydantic models to force LLMs to generate valid JSON or other structured formats.
- Flexible Deployment: Can be used as a Python library or deployed as a standalone REST API server via Flask.
- LLM Agnostic: Works with both proprietary and open-source LLMs.
Related
- Project
- Project
- Project
- Dispatch
- Project