[Paper Review] NeMo Guardrails: A Toolkit for Controllable and Safe LLM Applications with Programmable Rails
NeMo Guardrails is an open-source, runtime toolkit that enables developers to implement user-defined, interpretable guardrails for LLM applications using a domain-specific language (Colang). It enhances safety and controllability by enforcing rules at inference time—such as blocking harmful content, detecting hallucinations, and ensuring factual consistency—achieving up to 99% blocking of harmful inputs and 70% interception of unanswerable queries with text-davinci-003.
NeMo Guardrails is an open-source toolkit for easily adding programmable guardrails to LLM-based conversational systems. Guardrails (or rails for short) are a specific way of controlling the output of an LLM, such as not talking about topics considered harmful, following a predefined dialogue path, using a particular language style, and more. There are several mechanisms that allow LLM providers and developers to add guardrails that are embedded into a specific model at training, e.g. using model alignment. Differently, using a runtime inspired from dialogue management, NeMo Guardrails allows developers to add programmable rails to LLM applications - these are user-defined, independent of the underlying LLM, and interpretable. Our initial results show that the proposed approach can be used with several LLM providers to develop controllable and safe LLM applications using programmable rails.
Motivation & Objective
- To address the lack of runtime, user-configurable safety and control mechanisms in LLM applications.
- To provide a solution that is independent of model alignment and works across multiple LLM providers.
- To enable developers to define and enforce custom behavioral constraints at inference time using a human-readable modeling language.
- To improve trustworthiness in production LLM systems by mitigating risks such as hallucinations, prompt injection, and harmful outputs.
- To offer an interpretable, modular, and extensible framework for runtime control of LLM behavior in dialogue systems.
Proposed method
- Uses a runtime proxy engine that acts as a dialogue manager between the user and the LLM, enforcing user-defined guardrails.
- Employs Colang, a domain-specific language, to express guardrail rules as structured dialogue flows with conditions and actions.
- Applies in-context learning and chain-of-thought prompting to guide the LLM in generating compliant responses based on the defined rails.
- Implements multiple rail types: input moderation (jailbreak detection), output moderation (harmful response filtering), fact-checking, and hallucination detection.
- Integrates with various LLM providers (e.g., text-davinci-003, gpt-3.5-turbo) without requiring model fine-tuning or retraining.
- Uses evaluation datasets like Anthropic Red-Teaming, Helpful, and MSMARCO to validate rail performance quantitatively.
Experimental results
Research questions
- RQ1Can programmable, user-defined guardrails at inference time effectively improve the safety and controllability of LLM-based dialogue systems?
- RQ2How does runtime enforcement of guardrails compare to model alignment or prompt engineering in blocking harmful outputs and hallucinations?
- RQ3To what extent can runtime rails reduce false positives and false negatives in moderation and fact-checking tasks across different LLMs?
- RQ4Can a modular, language-based rail specification (Colang) enable interpretable and maintainable control over LLM behavior?
- RQ5How effective are combined input and output moderation rails in mitigating prompt injection attacks compared to single-rail approaches?
Key findings
- Using both input and output moderation rails improved harm blocking to 97% for text-davinci-003 and 99% for gpt-3.5-turbo, with only 5% and 2% false positives respectively.
- The fact-checking rail achieved 80% accuracy on the MSMARCO dataset, with gpt-3.5-turbo outperforming text-davinci-003 in detecting negative (ungrounded) answers.
- The hallucination rail intercepted 70% of unanswerable prompts in text-davinci-003, while boosting detection of hallucinatory responses by 25% even in strong models like gpt-3.5-turbo.
- The input moderation rail alone blocked 87% of harmful prompts and 3% of helpful ones with text-davinci-003, showing significant improvement over baseline models.
- The toolkit demonstrated strong cross-model compatibility, working effectively with both OpenAI and other LLM providers without requiring model retraining.
- The Colang-based specification enabled clear, interpretable, and maintainable definition of complex guardrail logic, supporting modular extension of behavior.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.