File size: 2,854 Bytes
a2a783b
c134413
 
ac8eec2
c134413
 
 
 
fcc2b05
 
 
0f43668
fa9e371
163e15b
d8ea208
fcc2b05
3cc6bb9
0a18f3d
fcc2b05
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cdf871b
fcc2b05
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6fd31b0
 
fcc2b05
 
 
 
d8ea208
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
87
88
---
library_name: transformers
license: other
base_model: Qwen/Qwen3-8B
tags:
- llama-factory
- full
- generated_from_trainer
---


**PsyLLM** is a large language model designed for **psychological counseling and mental health dialogue generation**. It integrates **diagnostic reasoning** and **therapeutic reasoning**, following established frameworks such as **DSM/ICD**, and incorporates diverse therapeutic approaches including **CBT**, **ACT**, and **psychodynamic therapy**.  

The model is trained on the [**OpenR1-Psy**](https://huggingface.co/datasets/GMLHUHE/OpenR1-Psy) dataset ([arXiv:2505.15715](https://arxiv.org/pdf/2505.15715v2)),  
featuring multi-turn counseling dialogues with explicit reasoning traces that support **clinically informed, empathetic, and interpretable** AI-assisted therapy.

The training process is implemented based on the open-source framework [**LLaMA-Factory**](https://github.com/hiyouga/LLaMA-Factory).

## 推理示例代码

```python
from transformers import AutoModelForCausalLM, AutoTokenizer

model_path = "GMLHUHE/PsyLLM"

# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(
    model_path,
    torch_dtype="auto",
    device_map="auto"
)

# prepare the model input
prompt = "I have participated in big group sessions before where I was left to find my own safe place, but it hasn't worked for me."
messages = [
    {"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
    enable_thinking=True 
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)

# conduct text completion
generated_ids = model.generate(
    **model_inputs,
    max_new_tokens=32768
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()

# parsing thinking content
try:
    index = len(output_ids) - output_ids[::-1].index(151668)
except ValueError:
    index = 0

thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")
content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")

print("PsyLLM thinking content:", thinking_content)
print("PsyLLM content:", content)
```

---

## 📄 Citation

If you use this dataset, please cite:

```bibtex
@article{hu2025beyond,
  title={Beyond Empathy: Integrating Diagnostic and Therapeutic Reasoning with Large Language Models for Mental Health Counseling},
  author={Hu, He and Zhou, Yucheng and Si, Juzheng and Wang, Qianning and Zhang, Hengheng and Ren, Fuji and Ma, Fei and Cui, Laizhong},
  journal={arXiv preprint arXiv:2505.15715},
  year={2025}
}
````

---

## 🧩 License

For **research and educational use only.**

Please ensure compliance with **ethical and legal standards** in mental health AI research.