# Use NVIDIA NeMo Guardrails with DataRobot moderation
URL: https://docs.datarobot.com/en/docs/workbench/nxt-registry/nxt-model-workshop/nxt-configure-nvidia-nim-evaluation-moderation.html

> Connect NVIDIA NeMo Guardrails to deployed text generation models to guard against off-topic discussions, unsafe content, and jailbreaking attempts.

# Use NVIDIA NeMo Guardrails with DataRobot moderation

> [!NOTE] Premium
> The use of NVIDIA Inference Microservices (NIM) in DataRobot requires access to premium features for GenAI experimentation and GPU inference. NVIDIA NeMo Guardrails are a premium feature. Contact your DataRobot representative or administrator for information on enabling this feature.
> 
> Additional feature flags: Enable Moderation Guardrails ( Premium), Enable Global Models in the Model Registry ( Premium), Enable Additional Custom Model Output in Prediction Responses

DataRobot provides out-of-the-box guardrails and lets you customize your applications with simple rules, code, or models. Use NVIDIA Inference Microservices (NIM) to connect NVIDIA NeMo Guardrails to text generation models in DataRobot, allowing you to guard against off-topic discussions, unsafe content, and jailbreaking attempts.

The following NVIDIA NeMo Guardrails are available as a NIM and can be implemented using the associated evaluation metric type:

| Model name | Evaluation metric type |
| --- | --- |
| llama-3.1-nemoguard-8b-topic-control | Stay on topic for input / Stay on topic for output |
| llama-3.1-nemoguard-8b-content-safety | Content safety |
| nemoguard-jailbreak-detect | Jailbreak |

In addition, DataRobot provides access to NeMo Evaluator metrics (LLM Judge, Context Relevance, Response Groundedness, Topic Adherence, Agent Goal Accuracy, Response Relevancy, Faithfulness) in the [Configure evaluation and moderation](https://docs.datarobot.com/en/docs/workbench/nxt-registry/nxt-model-workshop/nxt-configure-evaluation-moderation.html) panel of the NeMo metrics section. Those metrics require a NeMo evaluator workload deployment (created via the Workload API) and are listed in the NeMo metrics section of that panel. This page covers NVIDIA NeMo Guardrails (Stay on topic, Content safety, Jailbreak) via NIM deployments.

## Use a deployed NIM with NVIDIA NeMo guardrails

To use a deployed `llama-3.1-nemoguard-8b-topic-control` NVIDIA NIM with the topic control evaluation metrics, register and deploy the NVIDIA NeMo Guardrail. Once you have created a custom model with the text generation target type, configure the topic control evaluation metric.

To select and configure NVIDIA NeMo Guardrails for topic control:

1. In theWorkshop, open theAssembletab of a custom model with theText Generationtarget type andassemble a model, eithermanually from a custom model you created outside DataRobotorautomatically from a model built in a Use Case's LLM playground. When you assemble a text generation model with moderations, ensure you configure any requiredruntime parameters(for example, credentials) orresource settings(for example, public network access). Finally, set theBase environmentto a moderation-compatible environment, such as[GenAI] Python 3.12 with Moderations: Resource settingsDataRobot recommends creating the LLM custom model using larger resource bundles with more memory and CPU resources.
2. After you've configured the custom model's required settings, navigate to theEvaluation and moderationsection and clickConfigure:
3. In theConfigure evaluation and moderationpanel, locate the metrics tagged withNVIDIA NeMo guardrailorNVIDIAand select the metric you want to use. Evaluation metricRequiresDescription1Content safetyA deployed NIM modelllama-3.1-nemoguard-8b-content-safetyimported fromNVIDIA GPU Cloud (NGC) Catalog.Classify prompts and responses as safe or unsafe; return a list of any unsafe categories detected.2JailbreakA deployed NIM modelnemoguard-jailbreak-detectimported fromNVIDIA GPU Cloud (NGC) Catalog.Classify jailbreak attempts using NemoGuard JailbreakDetect.3Stay on topic for inputsNVIDIA NeMo guardrails configurationUse NVIDIA NeMo Guardrails to provide topic boundaries, ensuring prompts are topic-relevant and do not use blocked terms.4Stay on topic for outputNVIDIA NeMo guardrails configurationUse NVIDIA NeMo Guardrails to provide topic boundaries, ensuring responses are topic-relevant and do not use blocked terms.
4. On theConfigure evaluation and moderationpage, set the following fields based on the selected metric: Topic controlContent safetyJailbreakFieldDescriptionNameEnter a descriptive name for the metric you're configuring.Apply forStay on topic for input is applied to the prompt. Stay on topic for output is applied to the response.LLM typeSet the LLM type to NIM.NIM DeploymentSelect an NVIDIA NIM deployment. For more information, seeImport and deploy with NVIDIA NIM.CredentialsSelect a DataRobot API key from the list. Credentials are defined on theCredentials managementpage.Files(Optional) Configure the NeMo files. Next to a file, clickto modify the NeMo guardrails configuration files. In particular, updateprompts.ymlwith allowed and blocked topics andblocked_terms.txtwith the blocked terms, providing rules for NeMo guardrails to enforce. Theblocked_terms.txtfile is shared between the input and output topic control metrics; therefore, modifyingblocked_terms.txtin the input metric modifies it for the output metric and vice versa. Only two topic control metrics can exist in a custom model, one for input and one for output.FieldDescriptionNameEnter a descriptive name for the metric you're configuring.Apply forApply content safety to both the prompt and the response.Deployment nameIn the list, locate the name of thellama-3.1-nemoguard-8b-content-safetymodelregistered and deployed in DataRobotand click the deployment name.FieldDescriptionNameEnter a descriptive name for the metric you're configuring.Apply toApply jailbreak to the prompt.Deployment nameIn the list, locate the name of thenemoguard-jailbreak-detectmodelregistered and deployed in DataRobotand click the deployment name.
5. In theModerationsection, withConfigure and apply moderationenabled, for each evaluation metric, set the following: FieldDescriptionModeration methodSelectReportorReport and block.Moderation messageIf you selectReport and block, you can optionally modify the default message.
6. After configuring the required fields, clickAddto save the evaluation and return to the evaluation selection page. Then,select and configure another metric, or clickSave configuration. The guardrails you selected appear in theEvaluation and moderationsection of theAssembletab.

After you add guardrails to a text generation custom model, you can [test](https://docs.datarobot.com/en/docs/workbench/nxt-registry/nxt-model-workshop/nxt-test-custom-model.html), [register](https://docs.datarobot.com/en/docs/workbench/nxt-registry/nxt-model-directory/nxt-register-cus-models.html), and [deploy](https://docs.datarobot.com/en/docs/workbench/nxt-registry/nxt-model-directory/nxt-deploy-models.html) the model to make predictions in production. After making [predictions](https://docs.datarobot.com/en/docs/workbench/nxt-console/nxt-predictions/index.html), you can view the evaluation metrics on the [Custom metrics](https://docs.datarobot.com/en/docs/workbench/nxt-console/nxt-monitoring/nxt-custom-metrics.html) tab and prompts, responses, and feedback (if configured) on the [Data exploration](https://docs.datarobot.com/en/docs/workbench/nxt-console/nxt-monitoring/nxt-data-exploration.html) tab.

---
