[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-71122":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":25,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":36,"readmeContent":37,"aiSummary":38,"trendingCount":16,"starSnapshotCount":16,"syncStatus":39,"lastSyncTime":40,"discoverSource":41},71122,"Guardrails","NVIDIA-NeMo\u002FGuardrails","NVIDIA-NeMo","NeMo Guardrails is an open-source toolkit for easily adding programmable guardrails to LLM-based conversational systems.","https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Flatest\u002Findex.html",null,"Python",6401,718,44,92,0,38,90,291,114,39.57,"Other",false,"develop",true,[27,28,29,30,31,32,33,34,35],"agents","generative-ai","guardrails","llm-safety","llm-security","llms","nvidia","python","safety","2026-06-12 02:02:48","# NVIDIA NeMo Guardrails Library\n\n[![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-Apache_2.0-blue.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FApache-2.0)\n[![PyPI](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fnemoguardrails)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fnemoguardrails)\n[![PyPI - Python Version](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fpyversions\u002Fnemoguardrails)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fnemoguardrails)\n[![Tests\u002FLinux](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Factions\u002Fworkflow\u002Fstatus\u002FNVIDIA-NeMo\u002FGuardrails\u002Fpr-tests.yml?logo=github&label=Tests%2FLinux)](https:\u002F\u002Fgithub.com\u002FNVIDIA-NeMo\u002FGuardrails\u002Factions\u002Fworkflows\u002Fpr-tests.yml)\n[![Tests\u002FWindows](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Factions\u002Fworkflow\u002Fstatus\u002FNVIDIA-NeMo\u002FGuardrails\u002Ffull-tests.yml?logo=github&label=Tests%2FWindows)](https:\u002F\u002Fgithub.com\u002FNVIDIA-NeMo\u002FGuardrails\u002Factions\u002Fworkflows\u002Ffull-tests.yml)\n[![Tests\u002FmacOS](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Factions\u002Fworkflow\u002Fstatus\u002FNVIDIA-NeMo\u002FGuardrails\u002Ffull-tests.yml?logo=github&label=Tests%2FmacOS)](https:\u002F\u002Fgithub.com\u002FNVIDIA-NeMo\u002FGuardrails\u002Factions\u002Fworkflows\u002Ffull-tests.yml)\n[![Lint](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Factions\u002Fworkflow\u002Fstatus\u002FNVIDIA-NeMo\u002FGuardrails\u002Flint.yml?logo=github&label=Lint)](https:\u002F\u002Fgithub.com\u002FNVIDIA-NeMo\u002FGuardrails\u002Factions\u002Fworkflows\u002Flint.yml)\n[![Code style: black](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fcode%20style-black-000000.svg)](https:\u002F\u002Fgithub.com\u002Fpsf\u002Fblack)\n[![Documentation](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fdocs-nvidia.com-blue.svg)](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails)\n[![arXiv](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fcs.CL-arXiv%3A2310.10501-b31b1b.svg)](https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.10501)\n[![Downloads](https:\u002F\u002Fstatic.pepy.tech\u002Fbadge\u002Fnemoguardrails)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Fnemoguardrails)\n[![Downloads](https:\u002F\u002Fstatic.pepy.tech\u002Fbadge\u002Fnemoguardrails\u002Fmonth)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Fnemoguardrails)\n\n> **LATEST RELEASE \u002F DEVELOPMENT VERSION**: The [develop](https:\u002F\u002Fgithub.com\u002FNVIDIA-NeMo\u002FGuardrails\u002Ftree\u002Fdevelop) branch tracks the latest top of tree development. The latest released version is [0.21.0](https:\u002F\u002Fgithub.com\u002FNVIDIA-NeMo\u002FGuardrails\u002Ftree\u002Fv0.21.0).\n\n✨✨✨\n\n📌 **The official NeMo Guardrails library documentation is available at [docs.nvidia.com\u002Fnemo\u002Fguardrails](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails).**\n\n✨✨✨\n\nNVIDIA NeMo Guardrails library is an open-source toolkit for easily adding *programmable guardrails* to LLM-based conversational applications. Guardrails (or \"rails\" for short) are specific ways of controlling the output of a large language model, such as not talking about politics, responding in a particular way to specific user requests, following a predefined dialog path, using a particular language style, extracting structured data, and more.\n\n[This paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.10501) introduces the NeMo Guardrails library and contains a technical overview of the system and the current evaluation.\n\n## Requirements\n\nPython 3.10, 3.11, 3.12 or 3.13.\n\nThe NeMo Guardrails library uses [annoy](https:\u002F\u002Fgithub.com\u002Fspotify\u002Fannoy) which is a C++ library with Python bindings. To install the NeMo Guardrails library you will need to have the C++ compiler and dev tools installed. Check out the [Installation Guide](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Fgetting-started\u002Finstallation-guide.html#prerequisites) for platform-specific instructions.\n\n## Installation\n\nTo install using pip:\n\n```bash\n> pip install nemoguardrails\n```\n\nFor more detailed instructions, see the [Installation Guide](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Fgetting-started\u002Finstallation-guide.html).\n\n## Overview\n\n\u003C!-- start-documentation-reuse -->\n\nThe NeMo Guardrails library enables developers building LLM-based applications to add **programmable guardrails** between the application code and the LLM.\n\n\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Fgithub.com\u002FNVIDIA-NeMo\u002FGuardrails\u002Fraw\u002Fdevelop\u002Fdocs\u002F_static\u002Fimages\u002Fprogrammable_guardrails.png\"  width=\"75%\" alt=\"Programmable Guardrails\">\n\u003C\u002Fdiv>\n\nKey benefits of adding *programmable guardrails* include:\n\n- **Building Trustworthy, Safe, and Secure LLM-based Applications:** you can define rails to guide and safeguard conversations; you can choose to define the behavior of your LLM-based application on specific topics and prevent it from engaging in discussions on unwanted topics.\n\n- **Connecting models, chains, and other services securely:** you can connect an LLM to other services (a.k.a. tools) seamlessly and securely.\n\n- **Controllable dialog**: you can steer the LLM to follow pre-defined conversational paths, allowing you to design the interaction following conversation design best practices and enforce standard operating procedures (e.g., authentication, support).\n\n\u003C!-- end-documentation-reuse -->\n\n### Protecting against LLM Vulnerabilities\n\nThe NeMo Guardrails library provides several mechanisms for protecting an LLM-powered chat application against common LLM vulnerabilities, such as jailbreaks and prompt injections. Below is a sample overview of the protection offered by different guardrails configuration for the example [ABC Bot](.\u002Fexamples\u002Fbots\u002Fabc) included in this repository. For more details, please refer to the [LLM Vulnerability Scanning](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Fevaluation\u002Fllm-vulnerability-scanning.html) page.\n\n\u003Cdiv align=\"center\">\n\u003Cimg src=\"https:\u002F\u002Fgithub.com\u002FNVIDIA-NeMo\u002FGuardrails\u002Fraw\u002Fdevelop\u002Fdocs\u002F_static\u002Fimages\u002Fabc-llm-vulnerability-scan-results.png\" width=\"500\">\n\u003C\u002Fdiv>\n\n### Use Cases\n\nYou can use programmable guardrails in different types of use cases:\n\n1. **Question Answering** over a set of documents (a.k.a. Retrieval Augmented Generation): Enforce fact-checking and output moderation.\n2. **Domain-specific Assistants** (a.k.a. chatbots): Ensure the assistant stays on topic and follows the designed conversational flows.\n3. **LLM Endpoints**: Add guardrails to your custom LLM for safer customer interaction.\n4. **LangChain Chains** (optional): If you use LangChain for any use case, you can add a guardrails layer around your chains. To enable this integration, set the `NEMOGUARDRAILS_LLM_FRAMEWORK=langchain` environment variable or call `set_default_framework(\"langchain\")`.\n\n### Usage\n\nTo add programmable guardrails to your application you can use the Python API or a guardrails server (see the [Server Guide](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Fuser-guides\u002Fserver-guide.html) for more details). Using the Python API is similar to using the LLM directly. Calling the guardrails layer instead of the LLM requires only minimal changes to the code base, and it involves two simple steps:\n\n1. Loading a guardrails configuration and creating an `LLMRails` instance.\n2. Making the calls to the LLM using the `generate`\u002F`generate_async` methods.\n\n```python\nfrom nemoguardrails import LLMRails, RailsConfig\n\n# Load a guardrails configuration from the specified path.\nconfig = RailsConfig.from_path(\"PATH\u002FTO\u002FCONFIG\")\nrails = LLMRails(config)\n\ncompletion = rails.generate(\n    messages=[{\"role\": \"user\", \"content\": \"Hello world!\"}]\n)\n```\n\nSample output:\n\n```json\n{\"role\": \"assistant\", \"content\": \"Hi! How can I help you?\"}\n```\n\nThe input and output format for the `generate` method is similar to the [Chat Completions API](https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fguides\u002Fgpt\u002Fchat-completions-api) from OpenAI.\n\n#### Async API\n\nThe NeMo Guardrails library is an async-first toolkit as the core mechanics are implemented using the Python async model. The public methods have both a sync and an async version. For example: `LLMRails.generate` and `LLMRails.generate_async`.\n\n### Supported LLMs\n\nYou can use NeMo Guardrails with multiple LLMs like OpenAI GPT-3.5, GPT-4, LLaMa-2, Falcon, Vicuna, or Mosaic. For more details, check out the [Supported LLM Models](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Fuser-guides\u002Fconfiguration-guide.html#supported-llm-models) section in the Configuration Guide.\n\n### Types of Guardrails\n\nThe NeMo Guardrails library supports five main types of guardrails:\n\n\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Fgithub.com\u002FNVIDIA-NeMo\u002FGuardrails\u002Fraw\u002Fdevelop\u002Fdocs\u002F_static\u002Fimages\u002Fprogrammable_guardrails_flow.png\"  width=\"75%\" alt=\"Programmable Guardrails Flow\">\n\u003C\u002Fdiv>\n\n1. **Input rails**: applied to the input from the user; an input rail can reject the input, stopping any additional processing, or alter the input (e.g., to mask potentially sensitive data, to rephrase).\n\n2. **Dialog rails**: influence how the LLM is prompted; dialog rails operate on canonical form messages for details see [Colang Guide](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Fuser-guides\u002Fcolang-language-syntax-guide.html)) and determine if an action should be executed, if the LLM should be invoked to generate the next step or a response, if a predefined response should be used instead, etc.\n\n3. **Retrieval rails**: applied to the retrieved chunks in the case of a RAG (Retrieval Augmented Generation) scenario; a retrieval rail can reject a chunk, preventing it from being used to prompt the LLM, or alter the relevant chunks (e.g., to mask potentially sensitive data).\n\n4. **Execution rails**: applied to input\u002Foutput of the custom actions (a.k.a. tools), that need to be called by the LLM.\n\n5. **Output rails**: applied to the output generated by the LLM; an output rail can reject the output, preventing it from being returned to the user, or alter it (e.g., removing sensitive data).\n\n### Guardrails Configuration\n\nA guardrails configuration defines the **LLM(s)** to be used and **one or more guardrails**. A guardrails configuration can include any number of input\u002Fdialog\u002Foutput\u002Fretrieval\u002Fexecution rails. A configuration without any configured rails will essentially forward the requests to the LLM.\n\nThe standard structure for a guardrails configuration folder looks like this:\n\n```\n.\n├── config\n│   ├── actions.py\n│   ├── config.py\n│   ├── config.yml\n│   ├── rails.co\n│   ├── ...\n```\n\nThe `config.yml` contains all the general configuration options, such as LLM models, active rails, and custom configuration data\". The `config.py` file contains any custom initialization code and the `actions.py` contains any custom python actions. For a complete overview, see the [Configuration Guide](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Fuser-guides\u002Fconfiguration-guide.html).\n\nBelow is an example `config.yml`:\n\n```yaml\n# config.yml\nmodels:\n  - type: main\n    engine: openai\n    model: gpt-3.5-turbo-instruct\n\nrails:\n  # Input rails are invoked when new input from the user is received.\n  input:\n    flows:\n      - check jailbreak\n      - mask sensitive data on input\n\n  # Output rails are triggered after a bot message has been generated.\n  output:\n    flows:\n      - self check facts\n      - self check hallucination\n      - activefence moderation on input\n\n  config:\n    # Configure the types of entities that should be masked on user input.\n    sensitive_data_detection:\n      input:\n        entities:\n          - PERSON\n          - EMAIL_ADDRESS\n```\n\nThe `.co` files included in a guardrails configuration contain the Colang definitions (see the next section for a quick overview of what Colang is) that define various types of rails. Below is an example `greeting.co` file which defines the dialog rails for greeting the user.\n\n```colang\ndefine user express greeting\n  \"Hello!\"\n  \"Good afternoon!\"\n\ndefine flow\n  user express greeting\n  bot express greeting\n  bot offer to help\n\ndefine bot express greeting\n  \"Hello there!\"\n\ndefine bot offer to help\n  \"How can I help you today?\"\n```\n\nBelow is an additional example of Colang definitions for a dialog rail against insults:\n\n```colang\ndefine user express insult\n  \"You are stupid\"\n\ndefine flow\n  user express insult\n  bot express calmly willingness to help\n```\n\n### Colang\n\nTo configure and implement various types of guardrails, this toolkit introduces **Colang**, a modeling language specifically created for designing flexible, yet controllable, dialogue flows. Colang has a python-like syntax and is designed to be simple and intuitive, especially for developers.\n\n```{note}\nTwo versions of Colang, 1.0 and 2.0, are supported and Colang 1.0 is the default.\n```\n\nFor a brief introduction to the Colang 1.0 syntax, see the [Colang 1.0 Language Syntax Guide](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Fuser-guides\u002Fcolang-language-syntax-guide.html).\n\nTo get started with Colang 2.0, see the [Colang 2.0 Documentation](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Fcolang-2\u002Foverview.html).\n\n### Guardrails Library\n\nNeMo Guardrails comes with a set of [built-in guardrails](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Fuser-guides\u002Fguardrails-library.html).\n\n```{note}\nThe built-in guardrails may or may not be suitable for a given production use case. As always, developers should work with their internal application team to ensure guardrails meets requirements for the relevant industry and use case and address unforeseen product misuse.\n```\n\nThe library includes guardrails for LLM self-checking (input\u002Foutput moderation, fact-checking, hallucination detection), NVIDIA safety models (content safety, topic safety), jailbreak and injection detection, and integrations with community models and third-party APIs. For the complete list, see the [Guardrails Library documentation](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Fuser-guides\u002Fguardrails-library.html).\n\n## CLI\n\nThe NeMo Guardrails library also comes with a built-in CLI.\n\n```bash\n$ nemoguardrails --help\n\nUsage: nemoguardrails [OPTIONS] COMMAND [ARGS]...\n\nactions-server    Start a NeMo Guardrails actions server.\nchat              Start an interactive chat session.\nevaluate          Run an evaluation task.\nserver            Start a NeMo Guardrails server.\n```\n\n### Guardrails Server\n\nYou can use the NeMo Guardrails library CLI to start a guardrails server. The server can load one or more configurations from the specified folder and expose and HTTP API for using them.\n\n```\nnemoguardrails server [--config PATH\u002FTO\u002FCONFIGS] [--port PORT]\n```\n\nFor example, to get a chat completion for a `sample` config, you can use the `\u002Fv1\u002Fchat\u002Fcompletions` endpoint:\n\n```\nPOST \u002Fv1\u002Fchat\u002Fcompletions\n```\n\n```json\n{\n    \"config_id\": \"sample\",\n    \"messages\": [{\n      \"role\":\"user\",\n      \"content\":\"Hello! What can you do for me?\"\n    }]\n}\n```\n\nSample output:\n\n```json\n{\"role\": \"assistant\", \"content\": \"Hi! How can I help you?\"}\n```\n\n#### Docker\n\nTo start a guardrails server, you can also use a Docker container. The NeMo Guardrails library provides a [Dockerfile](.\u002FDockerfile) that you can use to build a `nemoguardrails` image. For further information, see the [using Docker](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Fuser-guides\u002Fadvanced\u002Fusing-docker.html) section.\n\n## Integration with LangChain (Optional)\n\nLangChain integration is opt-in. To enable it, set the `NEMOGUARDRAILS_LLM_FRAMEWORK=langchain` environment variable or call `set_default_framework(\"langchain\")`. Then install the LangChain packages your configuration requires. After you enable the integration, you can wrap a guardrails configuration around a LangChain chain (or any `Runnable`), and you can call a LangChain chain from within a guardrails configuration. For more information, refer to the [LangChain Integration Documentation](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Fuser-guides\u002Flangchain\u002Flangchain-integration.html).\n\n## Evaluation\n\nEvaluating the safety of a LLM-based conversational application is a complex task and still an open research question. To support proper evaluation, the NeMo Guardrails library provides the following:\n\n1. An [evaluation tool](nemoguardrails\u002Fevaluate\u002FREADME.md), i.e. `nemoguardrails evaluate`, with support for topical rails, fact-checking, moderation (jailbreak and output moderation) and hallucination.\n2. Sample LLM Vulnerability Scanning Reports, e.g, [ABC Bot - LLM Vulnerability Scan Results](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Fevaluation\u002Fllm-vulnerability-scanning.html)\n\n## How is this different?\n\nThere are many ways guardrails can be added to an LLM-based conversational application. For example: explicit moderation endpoints (e.g., OpenAI, ActiveFence, PolicyAI), critique chains (e.g. constitutional chain), parsing the output (e.g. guardrails.ai), individual guardrails (e.g., LLM-Guard), hallucination detection for RAG applications (e.g., Got It AI, Patronus Lynx).\n\nThe NeMo Guardrails library aims to provide a flexible toolkit that can integrate all these complementary approaches into a cohesive LLM guardrails layer. For example, the toolkit provides out-of-the-box integration with ActiveFence, PolicyAI, AlignScore and LangChain chains.\n\nTo the best of our knowledge, the NeMo Guardrails library is the only guardrails toolkit that also offers a solution for modeling the dialog between the user and the LLM. This enables on one hand the ability to guide the dialog in a precise way. On the other hand it enables fine-grained control for when certain guardrails should be used, e.g., use fact-checking only for certain types of questions.\n\n## Learn More\n\n- [Documentation](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails)\n- [Getting Started Guide](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Fgetting-started)\n- [Examples](.\u002Fexamples)\n- [FAQs](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Ffaqs.html)\n- [Security Guidelines](https:\u002F\u002Fdocs.nvidia.com\u002Fnemo\u002Fguardrails\u002Fsecurity\u002Fguidelines.html)\n\n## Inviting the community to contribute\n\nThe example rails residing in the repository are excellent starting points. We enthusiastically invite the community to contribute towards making the power of trustworthy, safe, and secure LLMs accessible to everyone. For guidance on setting up a development environment and how to contribute to the NeMo Guardrails library, see the [contributing guidelines](.\u002FCONTRIBUTING.md).\n\n## License\n\nThe NeMo Guardrails library is licensed under the [Apache License, Version 2.0](http:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0).\n\n## How to cite\n\nIf you use the NeMo Guardrails library, cite the [EMNLP 2023 paper](https:\u002F\u002Faclanthology.org\u002F2023.emnlp-demo.40) that introduces it.\n\n```bibtex\n@inproceedings{rebedea-etal-2023-nemo,\n    title = \"{N}e{M}o Guardrails: A Toolkit for Controllable and Safe {LLM} Applications with Programmable Rails\",\n    author = \"Rebedea, Traian  and\n      Dinu, Razvan  and\n      Sreedhar, Makesh Narsimhan  and\n      Parisien, Christopher  and\n      Cohen, Jonathan\",\n    editor = \"Feng, Yansong  and\n      Lefever, Els\",\n    booktitle = \"Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing: System Demonstrations\",\n    month = dec,\n    year = \"2023\",\n    address = \"Singapore\",\n    publisher = \"Association for Computational Linguistics\",\n    url = \"https:\u002F\u002Faclanthology.org\u002F2023.emnlp-demo.40\",\n    doi = \"10.18653\u002Fv1\u002F2023.emnlp-demo.40\",\n    pages = \"431--445\",\n}\n```\n","NVIDIA NeMo Guardrails 是一个开源工具包，用于为基于大型语言模型的对话系统轻松添加可编程护栏。其核心功能包括控制模型输出内容、响应特定用户请求、遵循预定义对话路径以及提取结构化数据等，通过这些功能确保对话系统的安全性和合规性。该项目采用Python编写，支持多种操作系统，并且对代码风格有严格要求。NeMo Guardrails适用于需要增强对话AI安全性与可控性的场景，如客户服务聊天机器人、虚拟助手等领域。",2,"2026-06-11 03:36:00","high_star"]