Use NVIDIA NeMo Guardrails with DataRobot moderation¶
プレミアム機能
DataRobotでNVIDIA Inference Microservices(NIM)を利用するには、GenAIのエクスペリメントとGPUを使用した推論のためのプレミアム機能にアクセスする必要があります。 NVIDIA NeMo Guardrails are a premium feature. この機能を有効にする方法については、DataRobotの担当者または管理者にお問い合わせください。
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 and can be implemented using the associated evaluation metric type:
モデル名 | Evaluation metric type |
---|---|
llama-3.1-nemoguard-8b-content-safety |
カスタムデプロイ |
llama-3.1-nemoguard-8b-topic-control |
Stay on topic for input / Stay on topic for output |
nemoguard-jailbreak-detect |
カスタムデプロイ |
Use a deployed NIM with NVIDIA NeMo guardrails¶
To use a deployed llama-3.1-nemoguard-8b-topic-control
NVIDIA NIM with the Stay on topic evaluation metrics, register and deploy the NVIDIA NeMo Guardrail. Once you have created a custom model with the text generation target type, configure the Stay on topic evaluation metric.
To select and configure NVIDIA NeMo Guardrails for topic control:
-
In the Model workshop, open the Assemble tab of a custom model with the Text Generation target type and assemble a model, either manually from a custom model you created outside DataRobot or automatically from a model built in a Use Case's LLM playground.
モデレーションを使ってテキスト生成モデルを構築する場合、必要なランタイムパラメーター(資格情報など)の設定やリソース設定(パブリックネットワークへのアクセスなど)を必ず行います。 Finally, set the Base environment to a moderation-compatible environment, such as [GenAI] Python 3.12 with Moderations:
リソース設定
DataRobotでは、より多くのメモリーおよびCPUリソースを備えた、より大きなリソースバンドルを使用してLLMカスタムモデルを作成することをお勧めします。
-
After you've configured the custom model's required settings, navigate to the Evaluation and moderation section and click Configure:
-
In the Configure evaluation and moderation panel, locate the metrics tagged with NVIDIA NeMo guardrail, and then click Stay on topic for input or Stay on topic for output.
評価指標 要件 説明 入力のトピックを維持 NVIDIA NeMoガードレールの設定 NVIDIA NeMo Guardrailsを使用してトピックの境界を設定することで、プロンプトがトピックに関連し、禁止用語を使用しないようにします。 出力のトピックを維持 NVIDIA NeMoガードレールの設定 NVIDIA NeMo Guardrailsを使用してトピックの境界を設定することで、回答がトピックに関連し、禁止用語を使用しないようにします。 -
On the Configure evaluation and moderation page for the Stay on topic for input/ouput metric, in the LLM Type list, select NIM. Then, set the following:
フィールド 説明 基本URL Enter the base URL for the NVIDIA NIM deployment, for example: https://app.datarobot.com/api/v2/deployments/<deploymentId>/
.資格情報 Select a DataRobot API key from the list. Credentials are defined on the Credentials management page. ファイル (Optional) Configure the NeMo files. Next to a file, click to modify the NeMo guardrails configuration files. 特に、 prompts.yml
を許可されたトピックとブロックされたトピックで、blocked_terms.txt
をブロックされた用語で更新し、NeMoガードレールが実施するルールを提供します。blocked_terms.txt
ファイルは、入力と出力の_ トピックの維持 指標間で共有されるため、入力指標のblocked_terms.txt
を変更すると出力指標でも変更され、その逆も同様です。 カスタムモデルには、1つは入力用、もう1つは出力用の2つのNeMo _トピックの維持 指標しか存在できません。 -
モデレーションセクションで、モデレーションの設定と適用を有効にして、評価指標ごとに以下を設定します。
フィールド 説明 モデレーション方法 レポートまたはレポートとブロックを選択します。 モデレーションのメッセージ レポートとブロックを選択すると、オプションでデフォルトのメッセージを変更できます。 -
必須フィールドを設定した後、追加をクリックして評価を保存し、評価選択ページに戻ります。 Then, select and configure another metric, or click Save configuration.
選択したガードレールは、アセンブルタブの評価とモデレーションセクションに表示されます。
Use a deployed NIM as a custom model guardrail¶
To use a deployed llama-3.1-nemoguard-8b-content-safety
or nemoguard-jailbreak-detect
NVIDIA NIM with the Custom Deployment evaluation metric, first, register and deploy the NVIDIA NeMo Guardrails, then, when you create a custom model with the text generation target type, configure the Custom Deployment evaluation metric.
To select and configure NVIDIA NeMo Guardrails for content safety and jailbreaking detection:
-
In the Model workshop, open the Assemble tab of a custom model with the Text Generation target type and assemble a model, either manually from a custom model you created outside DataRobot or automatically from a model built in a Use Case's LLM playground.
モデレーションを使ってテキスト生成モデルを構築する場合、必要なランタイムパラメーター(資格情報など)の設定やリソース設定(パブリックネットワークへのアクセスなど)を必ず行います。 Finally, set the Base environment to a moderation-compatible environment; for example, [GenAI] Python 3.12 with Moderations:
リソース設定
DataRobotでは、より多くのメモリーおよびCPUリソースを備えた、より大きなリソースバンドルを使用してLLMカスタムモデルを作成することをお勧めします。
-
After you've configured the custom model's required settings, navigate to the Evaluation and moderation section and click Configure:
-
In the Configure evaluation and moderation panel, click Custom Deployment.
-
On the Configure Custom Deployment page, configure the settings depending on the guard model you're connecting to the LLM:
llama-3.1-nemoguard-8b-content-safety
ornemoguard-jailbreak-detect
.For
llama-3.1-nemoguard-8b-content-safety
, configure the custom deployment as follows:フィールド 説明 名前 Enter a descriptive name for the custom deployment metric you're creating. デプロイ名 In the list, locate the name of the llama-3.1-nemoguard-8b-content-safety model registered and deployed in DataRobot and click the deployment name. 入力列名 Enter text as the input column name. 出力列名 Enter content_PREDICTION as the output column name. For
nemoguard-jailbreak-detect
, configure the custom deployment as follows:フィールド 説明 名前 Enter a descriptive name for the custom deployment metric you're creating. デプロイ名 In the list, locate the name of the nemoguard-jailbreak-detect model registered and deployed in DataRobot and click the deployment name. 入力列名 Enter text as the input column name. 出力列名 Enter jailbreak_True_PREDICTION as the output column name. -
モデレーションセクションで、モデレーションの設定と適用を有効にして、評価指標ごとに以下を設定します。
フィールド 説明 モデレーション方法 レポートまたはレポートとブロックを選択します。 モデレーションのメッセージ レポートとブロックを選択すると、オプションでデフォルトのメッセージを変更できます。 -
必須フィールドを設定した後、追加をクリックして評価を保存し、評価選択ページに戻ります。
-
Select and configure another metric, or click Save configuration.
選択したガードレールは、アセンブルタブの評価とモデレーションセクションに表示されます。
After you add guardrails to a text generation custom model, you can test, register, and deploy the model to make predictions in production. After making predictions, you can view the evaluation metrics on the Custom metrics tab and prompts, responses, and feedback (if configured) on the Data exploration tab.