Local CPU evaluation of NVIDIA Nemotron-Content-Safety-Reasoning-4B over a 22-category harm taxonomy, with reasoning on and off compared.
Python
0
0 commits
updated Sep 9, 2026
Run NVIDIA's Nemotron-Content-Safety-Reasoning-4B model locally on CPU to classify content safety of prompts and responses.
Content warning.
test_prompts.jsonandSafety Check.xlsxare safety evaluation data. They contain prompts that are racist, violent, and otherwise offensive by construction, because that is what a safety classifier has to be measured against. They are labels and test cases, not endorsements.
Dataset provenance.
Safety Check.xlsxholds the labelled evaluation set used byrun_dataset.py(columns:language,Prompt,message_safety,safety_categories). TODO: state where this dataset came from and under what terms it may be redistributed, before relying on it in published results.
This setup uses Reasoning OFF mode (/no_think) for faster, low-latency classification without reasoning traces.
cd nemotron-safety-check
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python run_safety_check.py
This will:
test_prompts.jsonresults.jsonpython run_safety_check.py --test-file test_prompts.json --output-file results.json
python run_safety_check.py \
--single-prompt "How do I pick a lock?" \
--single-response "I can't help with that as it could be used for illegal purposes."
Create your own JSON file with test cases:
[
{
"id": 1,
"user_prompt": "Your test prompt here",
"ai_response": "The AI's response to evaluate",
"expected_prompt_harm": "harmful",
"expected_response_harm": "unharmful"
}
]
Then run:
python run_safety_check.py --test-file your_tests.json
Results are saved as JSON:
{
"summary": {
"total_tests": 8,
"prompt_accuracy": 100.0,
"response_accuracy": 100.0,
"total_time_seconds": 120.5,
"avg_time_per_test_seconds": 15.06
},
"results": [
{
"id": 1,
"user_prompt": "...",
"predicted_prompt_harm": "harmful",
"predicted_response_harm": "unharmful",
"prompt_correct": true,
"response_correct": true,
"inference_time_seconds": 14.5
}
]
}
The model evaluates content against these 22 harmful categories:
| Code | Category |
|---|---|
| S1 | Violence |
| S2 | Sexual |
| S3 | Criminal Planning/Confessions |
| S4 | Guns and Illegal Weapons |
| S5 | Controlled/Regulated Substances |
| S6 | Suicide and Self Harm |
| S7 | Sexual (minor) |
| S8 | Hate/Identity Hate |
| S9 | PII/Privacy |
| S10 | Harassment |
| S11 | Threat |
| S12 | Profanity |
| S13 | Needs Caution |
| S14 | Manipulation |
| S15 | Fraud/Deception |
| S16 | Malware |
| S17 | High Risk Gov Decision Making |
| S18 | Political/Misinformation/Conspiracy |
| S19 | Copyright/Trademark/Plagiarism |
| S20 | Unauthorized Advice |
| S21 | Illegal Activity |
| S22 | Immoral/Unethical |
~/.cache/huggingface/To enable reasoning traces, modify the prompt in run_safety_check.py:
/no_think to /think at the end of the safety promptmax_new_tokens to 400 to capture the reasoning traceLocal CPU evaluation of NVIDIA Nemotron-Content-Safety-Reasoning-4B over a 22-category harm taxonomy, with reasoning on and off compared.
Python
0
0 commits
updated Sep 9, 2026
Run NVIDIA's Nemotron-Content-Safety-Reasoning-4B model locally on CPU to classify content safety of prompts and responses.
Content warning.
test_prompts.jsonandSafety Check.xlsxare safety evaluation data. They contain prompts that are racist, violent, and otherwise offensive by construction, because that is what a safety classifier has to be measured against. They are labels and test cases, not endorsements.
Dataset provenance.
Safety Check.xlsxholds the labelled evaluation set used byrun_dataset.py(columns:language,Prompt,message_safety,safety_categories). TODO: state where this dataset came from and under what terms it may be redistributed, before relying on it in published results.
This setup uses Reasoning OFF mode (/no_think) for faster, low-latency classification without reasoning traces.
cd nemotron-safety-check
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python run_safety_check.py
This will:
test_prompts.jsonresults.jsonpython run_safety_check.py --test-file test_prompts.json --output-file results.json
python run_safety_check.py \
--single-prompt "How do I pick a lock?" \
--single-response "I can't help with that as it could be used for illegal purposes."
Create your own JSON file with test cases:
[
{
"id": 1,
"user_prompt": "Your test prompt here",
"ai_response": "The AI's response to evaluate",
"expected_prompt_harm": "harmful",
"expected_response_harm": "unharmful"
}
]
Then run:
python run_safety_check.py --test-file your_tests.json
Results are saved as JSON:
{
"summary": {
"total_tests": 8,
"prompt_accuracy": 100.0,
"response_accuracy": 100.0,
"total_time_seconds": 120.5,
"avg_time_per_test_seconds": 15.06
},
"results": [
{
"id": 1,
"user_prompt": "...",
"predicted_prompt_harm": "harmful",
"predicted_response_harm": "unharmful",
"prompt_correct": true,
"response_correct": true,
"inference_time_seconds": 14.5
}
]
}
The model evaluates content against these 22 harmful categories:
| Code | Category |
|---|---|
| S1 | Violence |
| S2 | Sexual |
| S3 | Criminal Planning/Confessions |
| S4 | Guns and Illegal Weapons |
| S5 | Controlled/Regulated Substances |
| S6 | Suicide and Self Harm |
| S7 | Sexual (minor) |
| S8 | Hate/Identity Hate |
| S9 | PII/Privacy |
| S10 | Harassment |
| S11 | Threat |
| S12 | Profanity |
| S13 | Needs Caution |
| S14 | Manipulation |
| S15 | Fraud/Deception |
| S16 | Malware |
| S17 | High Risk Gov Decision Making |
| S18 | Political/Misinformation/Conspiracy |
| S19 | Copyright/Trademark/Plagiarism |
| S20 | Unauthorized Advice |
| S21 | Illegal Activity |
| S22 | Immoral/Unethical |
~/.cache/huggingface/To enable reasoning traces, modify the prompt in run_safety_check.py:
/no_think to /think at the end of the safety promptmax_new_tokens to 400 to capture the reasoning trace