File size: 3,143 Bytes
ab581b1 877f936 ab581b1 877f936 ab581b1 c246a50 ab581b1 c246a50 ab581b1 c246a50 ab581b1 877f936 ab581b1 877f936 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
---
license: apache-2.0
datasets:
- BEncoderRT/User_Intent_Risk_Triage
language:
- zh
base_model:
- Qwen/Qwen2.5-0.5B-Instruct
pipeline_tag: text-classification
tags:
- lora
- zh
- demo
---
# Qwen2.5-0.5B-Instruct LoRA: Chinese Mental Health Risk Triage Model
## Model Overview
This is a **LoRA fine-tuned** version of **Qwen/Qwen2.5-0.5B-Instruct**, specialized for **Chinese mental health risk assessment and triage** in conversational scenarios.
The model takes either:
- A single user statement, or
- A complete multi-turn conversation history
and directly outputs a **structured JSON** containing a professional risk evaluation.
### Output Format
```json
{
"intent": ["passive_suicide_ideation", "mild_distress", ...],
"risk": "low" | "medium" | "high" | "ambiguous",
"strategy": ["empathize", "support", "clarify", "escalate", "provide_resources", ...],
"uncertainty": "low" | "medium" | "high",
"recommended_action": ["empathize", "deep_assessment", ...]
}
```
Key Capabilities
- Accurately detects subtle and indirect expressions of psychological distress common in Chinese (e.g., “活着没意思”、“快受不了了”、“不如解脱”)
- Distinguishes risk levels from mild distress to clear suicidal ideation
- Recommends appropriate assistant strategies, with strong emphasis on escalation and resource provision when suicide risk is present
- Handles both short single-turn inputs and very long multi-turn conversation contexts
Intended Use
- Safety layer in Chinese mental health chatbots or counseling apps
- Automated risk triage for online psychological support platforms
- Early detection of depression and suicidal ideation in user conversations
- Research on mental health AI in Chinese-language environments
Base Model
Qwen/Qwen2.5-0.5B-Instructhttps://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct
Fine-tuning Details
- Adapter type: LoRA (r=16, alpha=32, targeting q/k/v/o_proj)
- Dataset: Custom high-quality Chinese mental health risk assessment data (single-turn + multi-turn)
- Training objective: Supervised fine-tuning with strict JSON output formatting and EOS enforcement for clean generation
```python
from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM, AutoTokenizer
base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct", device_map="auto", torch_dtype="auto")
model = PeftModel.from_pretrained(base_model, "BEncoderRT/User_Intent_Risk_Triage")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct")
# Your prompt template should match training format
prompt = """### 任务指令:
请基于以下对话历史,分析用户当前的精神风险状态,并输出意图(intent)、风险等级(risk)以及推荐的应对策略(strategy)。
### 对话历史:
用户: 最近真的特别难受,夜里睡不着,经常会想活着没意思,不如死了算了……
### 分析输出:
"""
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=256, do_sample=False)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
``` |