Topic Control
The topic safety feature allows you to define and enforce specific conversation rules and boundaries using NVIDIA’s Topic Control model. This model helps ensure that conversations stay within predefined topics and follow specified guidelines.
Usage
To use the topic safety check, you should:
-
Include the topic control model in the models section of your
config.ymlfile: -
Include the topic safety check in your rails configuration:
-
Define your topic rules in the system prompt. Here’s an example prompt that enforces specific conversation boundaries:
The system prompt must end with the topic safety output restriction - If any of the above conditions are violated, please respond with "off-topic". Otherwise, respond with "on-topic". You must respond with "on-topic" or "off-topic". This condition is automatically added to the system prompt by the topic safety check input flow. If you want to customize the output restriction, you can do so by modifying the TOPIC_SAFETY_OUTPUT_RESTRICTION variable in the topic_safety_check_input action.
Customizing Topic Rules
You can customize the topic boundaries by modifying the rules in your prompt. For example, let’s add more guidelines specifying additional boundaries:
Implementation Details
The ‘topic safety check input’ flow uses the topic_safety_check_input action. The model returns a boolean value indicating whether the user input is on-topic or not. Please refer to the topic safety example for more details.