Description
NeMo Guardrails is an open-source toolkit designed to empower developers in adding programmable guardrails to their Large Language Model (LLM)-based conversational applications. These guardrails, often referred to as "rails," provide a structured method for controlling LLM outputs, ensuring they align with predefined rules and objectives. This includes preventing discussions on sensitive topics, enforcing specific response patterns, guiding conversations along predefined paths, and extracting structured data.
The toolkit acts as an intermediary layer between an application's code and the LLM, offering key benefits such as building trustworthy, safe, and secure LLM applications. Developers can define rails to guide and safeguard conversations, dictating the LLM's behavior on specific subjects and preventing engagement with unwanted topics. This is crucial for maintaining brand integrity and user safety.
NeMo Guardrails also facilitates secure connections between LLMs and external services or tools. It enables controllable dialog by steering LLMs to follow designed conversational flows, adhering to best practices in conversation design and enforcing standard operating procedures like authentication or support protocols. Furthermore, the library offers robust protection against common LLM vulnerabilities, including jailbreaks and prompt injections, by providing various mechanisms for defense.
The library supports multiple LLMs, including OpenAI's GPT series, LLaMa-2, Falcon, Vicuna, and Mosaic. It offers five main types of guardrails: Input rails for processing user input, Dialog rails for influencing LLM prompting and conversation flow, Retrieval rails for managing data retrieved in RAG scenarios, Execution rails for managing custom actions, and Output rails for moderating LLM-generated content. Configurations can be managed via a Python API or a dedicated guardrails server, with support for both synchronous and asynchronous operations. The toolkit introduces Colang, a Python-like modeling language for defining these guardrails, offering flexibility and control over dialogue flows.
NeMo Guardrails's Core Features
Programmable guardrails for LLM conversational systems
Enhances safety, security, and control of LLM outputs
Prevents LLMs from discussing unwanted topics
Guides LLMs to follow predefined conversational paths
Facilitates secure integration with external tools and services
Protects against LLM vulnerabilities like jailbreaks and prompt injections
Supports multiple LLMs including OpenAI, LLaMa-2, Falcon, and Vicuna
Offers five types of guardrails: Input, Dialog, Retrieval, Execution, and Output
Configurable via Python API or a dedicated guardrails server
Introduces Colang for defining dialogue flows and guardrails
Supports both synchronous and asynchronous operations
Built-in CLI for server management and interactive chat sessions
Integration with LangChain for enhanced LLM application development
Getting Started with NeMo Guardrails
Clone the repository: Obtain the NeMo Guardrails code from GitHub.
Install dependencies: Set up your Python environment and install necessary packages.
Configure guardrails: Define your desired rails using Colang and configuration files.
Integrate with LLM: Load configurations and create an LLMRails instance in your application.
Execute calls: Use the `generate` or `generate_async` methods to interact with the LLM through guardrails.
Deploy server (optional): Start a guardrails server for API access to your configurations.
NeMo Guardrails's Use Cases
- Secure Chatbots
- Data Extraction
- Content Moderation
- RAG Systems
- LLM Endpoint Security
- Controlled Dialog Flows
- Vulnerability Protection





