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