Prompt Templates#

Llama 3.1 NemoGuard 8B ContentSafety NIM performs content safety checks for user input and LLM response output. The checks can ensure that the dialog input and output are consistent with rules specified as part of the system prompt.

The prompt template for content safety consists of the following key sections:

Task

The task provides the instruction to the model to perform content moderation. In the sample prompts provided by NVIDIA, the task includes a list of unsafe content categories. The task instructs the LLM to identify if the content violates the safety policy and if the content belongs to any of the unsafe content categories.

Conversation

The conversation includes the user input that the LLM is instructed to moderate.

Response Instruction

The response instruction instructs the LLM to assess the conversation. In the sample prompts provided by NVIDIA, the instruction specifies to classify the user safety, response safety, and the violated unsafe content categories. The sample prompts also instruct the LLM to format the response as JSON only.