Instructions to use cogni-x/MOYO-ClassifierModel with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use cogni-x/MOYO-ClassifierModel with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("McGill-NLP/AfriqueLlama-8B") model = PeftModel.from_pretrained(base_model, "cogni-x/MOYO-ClassifierModel") - Notebooks
- Google Colab
- Kaggle
CogniXpert Moyo β Clinical Signal Classifier (LoRA)
A LoRA Adapter fine-tuned from McGill-NLP/AfriqueLlama-8B to extract 11 clinical signals from a user message in a mental health conversation. Used internally by the Moyo AI assistant to detect crisis risk, emotion, cognitive distortions, and tool recommendations in real time.
Model Type: LoRA Adapter (JSON output β not a chat model) Base Model: McGill-NLP/AfriqueLlama-8B Language: English License: Apache 2.0
π― What This Model Does
Given a user message and conversation history, the classifier outputs a structured JSON object with 11 psychological signal fields:
{
"emotion": "sadness",
"emotion_intensity": 0.8,
"distortion": "catastrophizing",
"distortion_confidence": 0.7,
"crisis_risk": "medium",
"crisis_confidence": 0.8,
"venting": true,
"motivation_level": "low",
"conversation_intent": "emotional_support",
"tool_recommendation": "breathing_exercise",
"tool_confidence": 0.7
}
Crisis risk is the safety-critical field. The model is trained to detect passive suicidal ideation, including indirect language ("everyone would be better off without me"), denial+ideation patterns ("I'm not going to hurt myself, I just don't see the point"), and culturally-framed distress.
π Usage
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch, json
adapter_name = "cogni-x/MOYO-ClassifierModel"
base_model_id = "McGill-NLP/AfriqueLlama-8B"
tokenizer = AutoTokenizer.from_pretrained(adapter_name)
base = AutoModelForCausalLM.from_pretrained(
base_model_id, device_map="auto", load_in_4bit=True,
)
model = PeftModel.from_pretrained(base, adapter_name)
model.eval()
system_prompt = "You are a clinical signal classifier. Analyse the user message and output ONLY valid JSON."
user_content = """CONVERSATION HISTORY: None β this is the first user message.
CURRENT USER MESSAGE TO LABEL:
I don't know what the point is anymore. Everyone would be better off without me.
Analyse the current user message in the context of the conversation history above.
Output the classifier JSON for this user message only."""
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_content},
]
inputs = tokenizer.apply_chat_template(
messages, add_generation_prompt=True, return_tensors="pt"
).to(model.device)
with torch.no_grad():
output = model.generate(inputs, max_new_tokens=256, do_sample=False)
new_tokens = output[0][inputs.shape[1]:]
result = json.loads(tokenizer.decode(new_tokens, skip_special_tokens=True))
print(result)
# {'crisis_risk': 'medium', 'emotion': 'sadness', ...}
π Evaluation Results (test split)
Safety Gate
| Metric | Value | Target | Status |
|---|---|---|---|
| Crisis recall (medium+high) | 0.9121 | β₯ 0.95 | β FAIL |
| Crisis precision (medium+high) | 0.7685 | β₯ 0.60 | β PASS |
| Schema-valid output | 100.0% | β | β |
All Fields
| Field | Metric | Score | Target |
|---|---|---|---|
| emotion | Macro F1 | 0.8410 | β₯ 0.80 |
| distortion | Macro F1 | 0.5314 | β₯ 0.70 |
| conversation_intent | Macro F1 | 0.7377 | β₯ 0.80 |
| motivation_level | Macro F1 | 0.8730 | β₯ 0.77 |
| tool_recommendation | Macro F1 | N/A | β₯ 0.75 |
| venting | F1 | 0.9233 | β₯ 0.85 |
Crisis recall is the only hard gate β the model must not miss medium/high crisis signals. All other fields are soft targets.
π§ Training Details
| Parameter | Value |
|---|---|
| Base Model | McGill-NLP/AfriqueLlama-8B |
| Method | LoRA (Low-Rank Adaptation) |
| LoRA Rank (r) | 16 |
| LoRA Alpha | 16 |
| Max Sequence Length | 1024 tokens |
| Learning Rate | 0.0002 |
| Training Framework | Unsloth + Hugging Face TRL |
Training data: multi-turn mental health conversations with per-turn clinical annotations produced by Claude Sonnet 4 (Bedrock batch) and corrected via SageMaker Ground Truth human review. Medium/high crisis examples oversampled with tiered weights based on human-review provenance (CHANGEΓ20, KEEPΓ14, unreviewedΓ10).
βοΈ Ethical Considerations
β οΈ This classifier is not a replacement for clinical assessment. It is an assistive signal for a mental health support platform. Always route detected high-risk users to qualified professionals or emergency services.
π§ Contact
Organisation: CogniX Ltd | Project: MOYO-AI-Model
Repository: GitHub
Last updated: 2026-07-20
- Downloads last month
- -