NeMo Guardrails: A Toolkit for Controllable and Safe LLM Applications with Programmable Rails

TL;DR

NeMo Guardrails toolkit enables controllable and safe LLM applications with programmable rails.

cs.CL 🟡 Intermediate 2023-10-16 39 views
Traian Rebedea Razvan Dinu Makesh Sreedhar Christopher Parisien Jonathan Cohen
LLM dialogue systems safety controllability open-source toolkit

Key Findings

Methodology

NeMo Guardrails uses Colang to define dialogue flows, combining a dialogue manager and chain-of-thought (CoT) techniques to provide programmable rails. This approach is independent of model alignment, allowing users to define rails at runtime.

Key Results

  • On the Banking dataset, topical rails successfully guided dialogues using the falcon-7b-instruct model, significantly improving performance.
  • With the gpt-3.5-turbo model, input and output moderation rails effectively blocked 99% of harmful requests.
  • The fact-checking rail achieved 80% accuracy on the MS-MARCO dataset.

Significance

The toolkit provides developers with a flexible method to enhance the safety and controllability of LLM applications, especially in dialogue systems. By allowing programmable rails, developers can better control model outputs and avoid generating harmful content.

Technical Contribution

NeMo Guardrails offers a method independent of model alignment to control LLM outputs through programmable rails. This approach complements existing embedded rails, enhancing the flexibility and safety of dialogue systems.

Novelty

This is the first toolkit to use Colang for defining dialogue flows, allowing users to define and modify rails at runtime, offering greater flexibility than traditional model alignment.

Limitations

  • Runtime rail definition may lead to additional computational overhead and latency.
  • Developers need to manually define rails, increasing development complexity.

Future Work

Future work includes developing more powerful customized models to supplement current prompting methods and optimizing rail definitions to reduce latency and costs.

AI Executive Summary

NeMo Guardrails is an open-source toolkit designed to enhance the controllability and safety of large language model (LLM) applications through programmable rails. Existing LLMs often veer off-topic or generate inaccurate responses in dialogues, which NeMo Guardrails addresses by allowing developers to define dialogue flows and behavioral rules.

The toolkit uses Colang to define rails, combining chain-of-thought (CoT) and a dialogue manager to provide a flexible solution that enables developers to control model outputs at runtime. Initial experiments show that this approach performs well across multiple LLM providers, particularly in dialogue systems.

While NeMo Guardrails offers significant advantages, its runtime rail definition may lead to additional computational overhead and latency. Future work will focus on developing more powerful customized models and optimizing rail definitions to further improve the toolkit's efficiency and performance.

Deep Analysis

Background

In recent years, the rapid development of large language models (LLMs) has led to their widespread application in dialogue systems. However, these models often veer off-topic or generate inaccurate responses, and can even be exploited by malicious actors to produce harmful content. Existing solutions primarily rely on model alignment techniques, such as instruction tuning and reinforcement learning, which often require extensive human-labeled data.

Core Problem

LLMs in dialogues tend to veer off-topic or generate inaccurate responses, potentially being exploited to produce harmful content. This affects user experience and poses serious security issues. Thus, developing a tool to flexibly control LLM outputs is both crucial and challenging.

Innovation

NeMo Guardrails introduces the use of Colang to define dialogue flows, combined with chain-of-thought (CoT) and a dialogue manager, providing a method independent of model alignment. This allows developers to define and modify rails at runtime, offering greater flexibility than traditional model alignment.

Methodology

  • �� Use Colang to define dialogue flows, describing interaction rules between users and bots.
  • �� Employ chain-of-thought (CoT) techniques to guide LLMs in generating responses that adhere to rails.
  • �� Utilize a dialogue manager to interpret Colang code, ensuring the correct execution of dialogue flows.

Experiments

The experimental design includes testing with models from multiple LLM providers, such as falcon-7b-instruct and gpt-3.5-turbo. Evaluation metrics include dialogue guidance accuracy and safety, tested on datasets like Banking and MS-MARCO.

Results

On the Banking dataset, topical rails successfully guided dialogues, significantly improving performance with the falcon-7b-instruct model. Input and output moderation rails effectively blocked 99% of harmful requests with the gpt-3.5-turbo model. The fact-checking rail achieved 80% accuracy on the MS-MARCO dataset.

Applications

The toolkit can be used in dialogue systems requiring high security and controllability, such as customer service bots and medical consultation systems. Developers can define rails according to specific needs to ensure model outputs meet expectations.

Limitations & Outlook

While NeMo Guardrails offers significant advantages, its runtime rail definition may lead to additional computational overhead and latency. Additionally, rail definition requires manual input from developers, increasing development complexity. Future work will focus on optimizing rail definitions to reduce latency and costs.

Plain Language Accessible to non-experts

Imagine you're in a kitchen, and NeMo Guardrails is like a smart cooking assistant. It helps you follow specific recipes without deviating from the steps. Whenever you want to try a new recipe, it adjusts the steps based on your instructions, ensuring you don't add the wrong ingredients or steps. This way, even if you're a bit clumsy, it guarantees the dish is safe and delicious.

ELI14 Explained like you're 14

Imagine you're playing a game, and NeMo Guardrails is like a game assistant helping you follow the rules and stay on task. Whenever you want to try a new strategy, it adjusts the steps based on your instructions, ensuring you don't make mistakes. It's like having a reliable teammate always keeping you on the right track.

Glossary

Colang

A modeling language used to define dialogue flows, helping developers describe interaction rules between users and bots.

Used to define programmable rails in NeMo Guardrails.

Chain-of-Thought (CoT)

A technique that guides LLMs to generate responses adhering to rails by providing contextual examples to enhance reasoning.

Used to guide the generation of dialogue flows.

Dialogue Manager

A component responsible for interpreting Colang code and ensuring the correct execution of dialogue flows.

Used in NeMo Guardrails to manage dialogue flows.

Fact-Checking Rail

A mechanism that ensures response accuracy by verifying if generated responses are consistent with evidence.

Used to detect and avoid inaccurate model outputs.

Moderation Rails

Mechanisms used to detect and block potentially harmful inputs and outputs, ensuring dialogue safety.

Used in NeMo Guardrails to enhance dialogue system safety.

Open Questions Unanswered questions from this research

  • 1 How to optimize rail definitions without increasing computational overhead?
  • 2 How to automate rail generation to reduce developer workload?

Applications

Immediate Applications

Customer Service Bots

By defining specific rails, ensure customer service bots adhere to company policies and safety standards when handling user queries.

Long-term Vision

Medical Consultation Systems

Used in medical consultations to ensure generated advice meets medical standards, avoiding potential legal liabilities.

Abstract

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.

cs.CL cs.AI