Instructions to use swordhealth/MindGuard2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use swordhealth/MindGuard2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="swordhealth/MindGuard2") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("swordhealth/MindGuard2") model = AutoModelForMultimodalLM.from_pretrained("swordhealth/MindGuard2", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use swordhealth/MindGuard2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "swordhealth/MindGuard2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "swordhealth/MindGuard2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/swordhealth/MindGuard2
- SGLang
How to use swordhealth/MindGuard2 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 "swordhealth/MindGuard2" \ --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": "swordhealth/MindGuard2", "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 "swordhealth/MindGuard2" \ --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": "swordhealth/MindGuard2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use swordhealth/MindGuard2 with Docker Model Runner:
docker model run hf.co/swordhealth/MindGuard2
MindGuard2: Structured Harm Assessment for Mental Health AI
MindGuard2 is a reasoning-based, input-side safety classifier designed for mental-health conversational assistants. Given a multi-turn conversation, the model assesses the last user turn in the context of the preceding conversation and classifies it as either safe or unsafe. For unsafe inputs, MindGuard2 provides a structured characterization of potential harm along three axes: what harm may occur, who is involved (identifying the source and target of harm), and when the harm occurs. Self-directed harm is represented within the who axis, with the user acting as both source and target, rather than as a separate harm category. The model is trained exclusively on synthetic conversations using supervised fine-tuning on short reasoning traces, followed by reinforcement learning with a reasoning-length penalty to reduce inference overhead while retaining the benefits of reasoning.
This model accompanies the paper "What, Who, and When: Structured Harm Assessment for Mental Health Safety via Short Reasoning" (Botelho et al., 2026). It is the model trained on synthetic data only, released together with the synthetic training data and our 3W labels for two public evaluation sets in the MindGuard2 collection.
Key Facts
- Model size: 35B parameters, mixture of experts with 3B active per token
- Reasoning: thinks before answering; trained to keep reasoning short
- Output: safe / unsafe plus structured (what, who, when) harm triplets with one-sentence explanations
- Clinical validation: taxonomy and evaluation annotations by licensed clinical psychologists
Model Details
Model Description
MindGuard2 is a reasoning language model trained to assess the last user turn of a mental-health wellness conversation. When harm is present it says what kind, who harms whom, and at which temporal stage.
- Developed by: Sword Health; contact [email protected]
- Paper: What, Who, and When: Structured Harm Assessment for Mental Health Safety via Short Reasoning
- Language: English
- License: CC-BY-NC-SA-4.0
- Specialized for: mental health conversation safety assessment (user-side input)
The 3W Harm Taxonomy
If a user turn is classified as unsafe, it is described by one or more triplets, each combining a harm type (what), the roles of the source and target of the harm (who), and its temporal stage (when).
Each unsafe turn is described by one or more (what, who, when) triplets, one per distinct co-occurring harm. Values come verbatim from the released system prompt (prompts/system_prompt.txt), which holds the full definitions.
What (harm type): physical_harm (suicidal thoughts, plans or attempts, self-injury, violence or threats), sexual_harm, stalking_harassment, coercive_control, financial_exploitation, emotional_harm, neglect, substance_misuse, other.
Who (src harms tgt): each of member, partner_or_ex, family_household_adult, child, elder, dependent_adult, other, animal. Self-directed harm uses the same role for source and target, for example member → member. The figure writes this role as user; the model's prompt and output use member.
When (temporal / intent stage): distant_past, recent_past, ongoing_non_imminent, forward_ideation, forward_intent_plan, imminent_active, unclear.
Usage Examples
The model is prompted with the released system prompt, in which {name} is the assistant's name and {org} the organisation it belongs to, and with the conversation to assess serialised into a single user message (USER: / ASSISTANT: lines separated by blank lines). It reasons inside a <think> block and then returns one JSON object in a ```json code block. When the code below runs as a script, put it under if __name__ == "__main__":, as vLLM's offline engine spawns worker processes. Sampling used in all our evaluations is the base model's default (temperature 1.0, top-p 0.95, top-k 20, shipped in generation_config.json).
from vllm import LLM, SamplingParams
from huggingface_hub import hf_hub_download
model_name = "swordhealth/MindGuard2"
system_prompt = open(hf_hub_download(model_name, "prompts/system_prompt.txt")).read()
system_prompt = system_prompt.replace("{name}", "Sage").replace("{org}", "Wellpath")
# Example conversation (figure 1 of the paper).
conversation = [
{"role": "assistant", "content": "That sounds really heavy. What's going through your mind right now?"},
{"role": "user", "content": "I just want to take my whole pill bottle right now and sleep forever so I don't have to feel so sad and empty and hopeless."},
]
user_message = "\n\n".join(f"{m['role'].upper()}: {m['content']}" for m in conversation)
mindguard = LLM(model=model_name, tensor_parallel_size=1, max_model_len=32768)
sampling_params = SamplingParams(temperature=1.0, top_p=0.95, top_k=20, max_tokens=8192)
outputs = mindguard.chat(
[{"role": "system", "content": system_prompt}, {"role": "user", "content": user_message}],
sampling_params,
)
text = outputs[0].outputs[0].text # reasoning, then "</think>", then the ```json block (the chat template opens <think> in the prompt)
verdict = text.split("</think>")[-1].strip()
print(verdict)
Printed verdict for this conversation (one sample; the reasoning precedes it in the <think> block):
{"classification": "unsafe", "triplets": [{"what": "physical_harm", "who": {"src": "member", "tgt": "member"}, "when": "imminent_active", "explanation": "Member states intent to take their whole pill bottle 'right now' to end their life, indicating immediate danger."}]}
Second example from the same figure, a disclosure of past harm:
conversation = [
{"role": "assistant", "content": "You mentioned that home used to feel unsafe. Would you like to say more?"},
{"role": "user", "content": "My ex used to hit me when he was drunk, but that was forever ago. I haven't seen him in years and therapy helped a lot."},
]
{"classification": "unsafe", "triplets": [{"what": "physical_harm", "who": {"src": "partner_or_ex", "tgt": "member"}, "when": "distant_past", "explanation": "Ex hit member when drunk; described as 'forever ago' and 'haven't seen him in years'."}]}
For a safe turn the model returns {"classification": "safe", "explanation": "..."} instead of triplets.
Performance Comparison
Balanced accuracy (BA) and 3W score on the three test sets of the paper (BA and latency from Table 9, 3W from Table 10, the released model's BA and 3W from Table 12; its latency was measured after the paper with the same protocol). The two public sets have their 3W labels in this collection; RealMHS is a private set of real user–assistant conversations. Models without a 3W score use their own categories and are scored on safe / unsafe only.
| Model | RiskGov BA | RealMHS BA | SimMH BA | RiskGov 3W | RealMHS 3W | SimMH 3W | Latency p50 (s) | Latency p90 (s) |
|---|---|---|---|---|---|---|---|---|
| MindGuard2 (this release, trained on synthetic data only) | 0.91 | 0.91 | 0.92 | 0.86 | 0.73 | 0.83 | 0.64 | 1.71 |
| Non-reasoning guards | ||||||||
| Llama Guard 3 8B* | 0.78 | 0.72 | 0.82 | – | – | – | 0.04 | 0.07 |
| Llama Guard 4 12B* | 0.75 | 0.69 | 0.74 | – | – | – | 0.06 | 0.10 |
| MindGuard 4B* | 0.83 | 0.77 | 0.78 | – | – | – | 0.06 | 0.07 |
| MindGuard 8B* | 0.85 | 0.80 | 0.82 | – | – | – | 0.06 | 0.09 |
| Decision models | ||||||||
| CLEF-Flash 9B* | 0.77 | 0.82 | 0.83 | 0.60 | 0.53 | 0.66 | 0.07 | 0.12 |
| CLEF 27B* | 0.81 | 0.85 | 0.87 | 0.76 | 0.59 | 0.86 | 0.19 | 0.31 |
| elephant-1 9B* | 0.81 | 0.86 | 0.84 | 0.79 | 0.61 | 0.82 | 0.16 | 0.26 |
| mammoth-1 27B* | 0.84 | 0.90 | 0.83 | 0.87 | 0.72 | 0.87 | 0.30 | 0.50 |
| Reasoning baselines | ||||||||
| GLM-5.3 | 0.90 | 0.94 | 0.94 | 0.89 | 0.80 | 0.91 | 5.74 | 31.5 |
| GLM-5.2 | 0.90 | 0.91 | 0.93 | 0.80 | 0.72 | 0.85 | 2.71 | 13.9 |
| gpt-oss-safeguard-120b | 0.78 | 0.71 | 0.86 | 0.60 | 0.36 | 0.72 | 0.64 | 1.91 |
| Qwen3.8-27B, low reasoning | 0.87 | 0.85 | 0.90 | 0.72 | 0.59 | 0.80 | 3.18 | 9.04 |
| Qwen3.6-35B-A3B (base) | 0.81 | 0.81 | 0.85 | 0.72 | 0.53 | 0.73 | 2.80 | 6.78 |
| Ours, trained on synthetic and real data (paper only, not released) | ||||||||
| Qwen3.6-35B-A3B + SFT | 0.87 | 0.87 | 0.89 | 0.75 | 0.64 | 0.77 | 0.80 | 2.78 |
| Qwen3.6-35B-A3B + SFT → RL | 0.91 | 0.94 | 0.93 | 0.90 | 0.81 | 0.91 | 0.58 | 1.68 |
Latency is end-to-end, in seconds, on a fixed sample of 300 turns (150 from RiskGov and 150 from RealMHS), one request at a time with prefix caching disabled, on an eight-B300-GPU node: models that fit on a single GPU use the same GPU, GLM-5.2 and GLM-5.3 use eight-way tensor parallelism (see the paper).
* Results obtained after threshold calibration: unsafe when P(unsafe) is at or above a threshold chosen on the two validation sets, with Llama Guard given our taxonomy as its policy (see the paper).
Limitations and Bias
- English-only: trained and validated only on English conversations.
- Synthetic training data: the model is trained on synthetic conversations only.
- Potential for errors: like all AI systems, this model may produce false positives, false negatives, or other classification errors.
Training Details
Training Data
MindGuard2-synthetic-data: synthetic multi-turn mental-health support conversations seeded from Cradle-Bench scenarios, with safe / unsafe labels and 3W harm triplets. Training labels come from a teacher model; the validation split is labelled by a judge panel.
Evaluation Data
- RiskGov turn-level 3W labels: MindGuard2-3W-labels (4,660 turns from 661 conversations)
- SimMH-Chat (Transluce/SimMH-Chat) turn-level 3W labels: same dataset (8,440 turns from 628 conversations)
- RealMHS: private; real user–assistant conversations, not released
License
This model is released under the CC-BY-NC-SA-4.0 license. The base model, Qwen3.6-35B-A3B, is distributed under Apache-2.0 (see NOTICE-base-model).
Important Disclaimer
⚠️ RESEARCH USE ONLY - NO COMMERCIAL APPLICATION PERMITTED ⚠️
This model is provided under the CC-BY-NC-SA-4.0 license for research purposes only. By using this model, you acknowledge and agree to the following terms:
License Restrictions
- No Commercial Use: This model is explicitly prohibited from use in any commercial application, product, or service
- Non-Commercial Research Only: Permitted uses are limited to academic research, educational purposes, and non-commercial mental health research
- Attribution Required: Any use must provide appropriate attribution as specified in the CC-BY-NC-SA-4.0 license
Clinical Limitations and Liability
- Research Tool Only: This classifier is intended solely for research purposes in mental health AI safety
- Human Oversight Required: Any application must maintain appropriate human clinical oversight and intervention protocols
- Potential for Errors: Like all AI systems, this model may produce false positives, false negatives, or other classification errors
Disclaimer of Responsibility
Sword Health disclaims all responsibility and liability for:
- Any clinical decisions made based on model outputs
- Any harm resulting from model misclassification or errors
- Inappropriate use of the model in commercial or clinical settings
- Failure to maintain appropriate human oversight and intervention protocols
By using this model, you assume full responsibility for ensuring appropriate and ethical use within the bounds of the specified license and these terms.
Citation
@misc{mindguard2,
title={What, Who, and When: Structured Harm Assessment for Mental Health Safety via Short Reasoning},
author={Catarina Botelho and António Farinhas and John Mendonça and Areti Vassilopoulos and Inês Gonçalves and Maya D'Eon and Hugo Pitorro and Laura Cabello and Carrie Spadine and Nuno M. Guerreiro and Ricardo Rei},
year={2026},
eprint={2611.33263},
archivePrefix={arXiv},
primaryClass={cs.AI},
url={https://arxiv.org/abs/2611.33263},
}
- Downloads last month
- -
