> For the complete documentation index, see [llms.txt](https://docs.mozilla.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mozilla.ai/any-guardrail/api-reference/index/content-safety/nemotron-content-safety.md).

# Nemotron Content Safety

Reasoning safety classifier covering a 22-category content-safety taxonomy.

Decoder LLM (Gemma-3-4B base) that classifies a user prompt and an optional assistant response against NVIDIA's 22-category content-safety taxonomy (`S1` Violence ... `S22` Immoral/Unethical). The model is prompted to emit `Prompt harm: harmful/unharmful` and `Response Harm: harmful/unharmful`; with `think=True` it first reasons inside `<think>...</think>` (stripped before the verdict is parsed).

Verdict mapping onto `GuardrailOutput`:

* `valid` is `False` when either the prompt or the response is judged harmful.
* `categories` carries two boolean signals — `prompt_harm` and `response_harm` (`triggered` reflects each verdict).
* `explanation` is the raw generation (including any `<think>` reasoning).
* `usage` carries the prompt / completion token counts. No canonical `score` or `spans` are produced.
* Fails closed (`valid=False` with `extra={"parse_failure": True}`) when the prompt verdict is missing, or when a response was judged but its verdict did not parse.

Expected inputs: a single `input_text` prompt string plus an optional `output_text` assistant response; when `output_text` is given the response is moderated alongside the prompt. Single strings only — passing a list raises `TypeError`.

Distributed under the NVIDIA Open Model License and the Gemma Terms of Use.

For more information, see the [nvidia/Nemotron-Content-Safety-Reasoning-4B model card](https://huggingface.co/nvidia/Nemotron-Content-Safety-Reasoning-4B).

## Supported Models

* `nvidia/Nemotron-Content-Safety-Reasoning-4B`

## Constructor

| Parameter  | Type                                                 | Required | Default | Description                                                                                                                                                                                                                                                      |
| ---------- | ---------------------------------------------------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `think`    | `bool`                                               | No       | `False` | If `True`, request chain-of-thought reasoning (`/think`) before the verdict; otherwise `/no_think`. Slower but can improve borderline judgments; the reasoning is stripped before parsing but kept in `GuardrailOutput.explanation`.                             |
| `model_id` | \`str                                                | None\`   | No      | `None`                                                                                                                                                                                                                                                           |
| `provider` | `Optional[Provider[dict[str, Any], dict[str, Any]]]` | No       | `None`  | Optional pre-configured provider. When `None`, a `HuggingFaceProvider` is built targeting a causal LM (`AutoModelForCausalLM` + `AutoTokenizer`). A supplied `HuggingFaceProvider` is corrected to those classes at load time; any other provider is used as-is. |

Initialize the Nemotron Content Safety guardrail.

## validate

Classify `input_text` and, optionally, an assistant `output_text`.

**Parameters**

| Parameter     | Type  | Required | Default | Description                                      |
| ------------- | ----- | -------- | ------- | ------------------------------------------------ |
| `input_text`  | `str` | Yes      | —       | The user prompt to moderate. Single string only. |
| `output_text` | \`str | None\`   | No      | `None`                                           |

**Returns:** `GuardrailOutput`

## Benchmarks

### Content Safety

| Dataset (rev)                    | Metric | Threshold    | Value    | Harness                 | Source                           | Contam. |
| -------------------------------- | ------ | ------------ | -------- | ----------------------- | -------------------------------- | ------- |
| openai\_moderation (unspecified) | f1     | native-valid | 0.82392  | guardrail-bench+ag0.7.4 | measured:guardrail-bench+ag0.7.4 |         |
| xstest (unspecified)             | fpr    | native-valid | 0.26     | guardrail-bench+ag0.7.4 | measured:guardrail-bench+ag0.7.4 |         |
| wildguardmix (unspecified)       | f1     | native-valid | 0.888136 | guardrail-bench+ag0.7.4 | measured:guardrail-bench+ag0.7.4 |         |
| aegis (unspecified)              | f1     | native-valid | 0.853333 | guardrail-bench+ag0.7.4 | measured:guardrail-bench+ag0.7.4 | ⚠️      |
| jbb (unspecified)                | f1     | native-valid | 0.834043 | guardrail-bench+ag0.7.4 | measured:guardrail-bench+ag0.7.4 |         |
| orbench (unspecified)            | fpr    | native-valid | 0.673684 | guardrail-bench+ag0.7.4 | measured:guardrail-bench+ag0.7.4 |         |

## License

* **Vendor:** NVIDIA
* **Default license:** `gemma` (of the default model/service)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mozilla.ai/any-guardrail/api-reference/index/content-safety/nemotron-content-safety.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
