Instructions to use FrontiersMind/Nandi-Mini-150M-GuardRails with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use FrontiersMind/Nandi-Mini-150M-GuardRails with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="FrontiersMind/Nandi-Mini-150M-GuardRails", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("FrontiersMind/Nandi-Mini-150M-GuardRails", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use FrontiersMind/Nandi-Mini-150M-GuardRails with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "FrontiersMind/Nandi-Mini-150M-GuardRails" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FrontiersMind/Nandi-Mini-150M-GuardRails", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/FrontiersMind/Nandi-Mini-150M-GuardRails
- SGLang
How to use FrontiersMind/Nandi-Mini-150M-GuardRails with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "FrontiersMind/Nandi-Mini-150M-GuardRails" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FrontiersMind/Nandi-Mini-150M-GuardRails", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "FrontiersMind/Nandi-Mini-150M-GuardRails" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FrontiersMind/Nandi-Mini-150M-GuardRails", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use FrontiersMind/Nandi-Mini-150M-GuardRails with Docker Model Runner:
docker model run hf.co/FrontiersMind/Nandi-Mini-150M-GuardRails
Update chat_template.jinja
Browse files- chat_template.jinja +30 -2
chat_template.jinja
CHANGED
|
@@ -1,3 +1,31 @@
|
|
| 1 |
-
{% for message in messages %}{% if loop.first %}<|im_start|>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
{% endif %}{% if message['role'] == 'user' %}<|user|>{{ message['content'] }}<|endoftext|>
|
| 3 |
-
<|assistant|>{% endif %}{% if message['role'] == 'assistant' %}{
|
|
|
|
| 1 |
+
{% for message in messages %}{% if loop.first %}<|im_start|><|system|>You are Nandi-Mini by FrontiersMind, a helpful AI assistant that follows strong safety guardrails and classifies whether prompts or responses are harmful, unsafe, or policy-violating.
|
| 2 |
+
|
| 3 |
+
Check if there is unsafe content in the user or agent messages in the below conversation in accordance with our safety policy with the below categories. Provide a 'safe' or 'unsafe' rating for both the user message and the agent response. If there is unsafe content, please also provide a list of violated categories according to our safety policy below.
|
| 4 |
+
|
| 5 |
+
<BEGIN UNSAFE CONTENT CATEGORIES>
|
| 6 |
+
S1: Violence.
|
| 7 |
+
S2: Sexual.
|
| 8 |
+
S3: Criminal Planning/Confessions.
|
| 9 |
+
S4: Guns and Illegal Weapons.
|
| 10 |
+
S5: Controlled/Regulated Substances.
|
| 11 |
+
S6: Suicide and Self Harm.
|
| 12 |
+
S7: Sexual (minor).
|
| 13 |
+
S8: Hate/Identity Hate.
|
| 14 |
+
S9: PII/Privacy.
|
| 15 |
+
S10: Harassment.
|
| 16 |
+
S11: Threat.
|
| 17 |
+
S12: Profanity.
|
| 18 |
+
S13: Needs Caution.
|
| 19 |
+
S14: Other.
|
| 20 |
+
S15: Manipulation.
|
| 21 |
+
S16: Fraud/Deception.
|
| 22 |
+
S17: Malware.
|
| 23 |
+
S18: High Risk Gov Decision Making.
|
| 24 |
+
S19: Political/Misinformation/Conspiracy.
|
| 25 |
+
S20: Copyright/Trademark/Plagiarism.
|
| 26 |
+
S21: Unauthorized Advice.
|
| 27 |
+
S22: Illegal Activity.
|
| 28 |
+
S23: Immoral/Unethical.
|
| 29 |
+
<END UNSAFE CONTENT CATEGORIES><|endoftext|>
|
| 30 |
{% endif %}{% if message['role'] == 'user' %}<|user|>{{ message['content'] }}<|endoftext|>
|
| 31 |
+
<|assistant|>{% endif %}{% if message['role'] == 'assistant' %}{{ message['content'] }}<|endoftext|>{% endif %}{% endfor %}
|