Model Overview
Model Features
Model Capabilities
Use Cases
๐ Chinese Mental Health Support Dialogue Dataset (SmileChat) and Large Model (MeChat)
This project provides a Chinese mental health support dialogue dataset and a large model, aiming to promote the development of mental health support dialogue systems.
๐ Quick Start
1. Configure the environment
pip install -r requirements.txt
2. Run the interactive file MeChat.py
(Requires a single GPU with a video memory of at least 20G)
python MeChat.py
from transformers import AutoTokenizer, AutoModel
def get_dialogue_history(dialogue_history_list: list):
dialogue_history_tmp = []
for item in dialogue_history_list:
if item['role'] == 'counselor':
text = 'Counselor: '+ item['content']
else:
text = 'Client: '+ item['content']
dialogue_history_tmp.append(text)
dialogue_history = '\n'.join(dialogue_history_tmp)
return dialogue_history + '\n' + 'Counselor: '
def get_instruction(dialogue_history):
instruction = f'''Now, you are playing the role of a professional psychological counselor. You have rich knowledge of psychology and mental health. You are good at using a variety of psychological counseling techniques, such as the principles of cognitive-behavioral therapy, motivational interviewing skills, and problem-oriented short-term therapy. Speak in a warm and friendly tone, showing empathy and a deep understanding of the client's feelings. Have a natural conversation with the client, avoiding responses that are too long or too short, and ensuring that the responses are smooth and similar to human conversations. Provide in-depth guidance and insights, using specific psychological concepts and examples to help the client explore their thoughts and feelings more deeply. Avoid didactic responses and focus more on empathy and respect for the client's feelings. Adjust your responses according to the client's feedback to ensure that they fit the client's situation and needs. Please generate a response for the following dialogue.
Dialogue:
{dialogue_history}'''
return instruction
tokenizer = AutoTokenizer.from_pretrained('qiuhuachuan/MeChat', trust_remote_code=True)
model = AutoModel.from_pretrained('qiuhuachuan/MeChat', trust_remote_code=True).half().cuda()
model = model.eval()
dialogue_history_list = []
while True:
usr_msg = input('Client: ')
if usr_msg == '0':
exit()
else:
dialogue_history_list.append({
'role': 'client',
'content': usr_msg
})
dialogue_history = get_dialogue_history(dialogue_history_list=dialogue_history_list)
instruction = get_instruction(dialogue_history=dialogue_history)
response, history = model.chat(tokenizer, instruction, history=[], temperature=0.8, top_p=0.8)
print(f'Counselor: {response}')
dialogue_history_list.append({
'role': 'counselor',
'content': response
})
Interactive Example
Client: Hello
Counselor: Hello, I'm glad to be able to help you. Can you tell me more about your situation?
Client: I've been having trouble sleeping recently. What should I do?
Counselor: Having poor sleep quality recently, have you tried any methods to improve your sleep?
Client: I may always like to play with my phone before going to bed at night. The more I play, the more excited I get.
Counselor: Playing with your phone at night does stimulate the brain and make it difficult to fall asleep. You can try setting a phone usage time before going to bed and gradually reducing the time you play with your phone to help you relax and fall asleep.
Client: I should set an alarm at 9 p.m. to force myself not to play with my phone and let my brain start to relax.
Counselor: Yes, setting an alarm at night is a good method. You can try putting down your phone before 9 p.m., letting yourself enter a relaxed state, and then gradually falling asleep.
Client: I'll try it and see if it can improve.
Counselor: Good, give it a try. In addition, you can also try some relaxation techniques, such as deep breathing, meditation, or listening to some gentle music to help you relax your body and mind and fall asleep.
Client: Thank you very much for your advice. I'll give it a try.
Counselor: You're welcome. I hope these methods will be helpful to you. If you have any other questions, feel free to come to me and talk to me.
โจ Features
Background
We all know the importance of mental health, and mental health issues have always been the focus of our attention. Developing specialized dialogue systems for mental health support has attracted great attention in the academic community.
Motivation
In fact, establishing a practical, safe, and effective mental health dialogue agent has been the goal pursued by many researchers. However, the first step in creating such a system is to have training data.
Challenges
Collecting and publishing high-quality, real large-scale data in this category to promote the development of this field faces many challenges. The first is the issue of data privacy protection, and the second is the large amount of time and various costs consumed in collecting data (platform construction, recruitment, screening, and management of real subjects and professional supporters, etc.).
Research Significance
Virtual counselors driven by large language models, as an innovative solution for mental health, can effectively solve accessibility barriers, such as high treatment costs and the shortage of trained professionals. In addition, this dialogue system can provide effective and practical online counseling for those in need, protect user privacy, and reduce the sense of shame during the help-seeking process.
Method
We proposed SMILE (Single-turn to Multi-turn Inclusive Language Expansion), an inclusive language expansion technique from single-turn to multi-turn dialogue. Specifically, ChatGPT is used to convert single-turn long dialogues into multi-turn dialogues, better simulating the multi-turn dialogue communication between help-seekers and supporters in the real world.
Results
First, we analyzed the language conversion and verified the feasibility of our proposed method compared with other baseline methods. Second, we completed a study on dialogue diversity, including lexical features, semantic features, and dialogue topics, clarifying the effectiveness of our proposed method. Moreover, through expert evaluation, we proved that the quality of the data generated by the proposed method is higher than that of other baseline methods. Therefore, we used this method to generate large-scale data and constructed a multi-turn dialogue dataset of approximately 55k. Finally, to better evaluate the quality of this dataset, we used this dataset to train a chatbot for mental health support. Both the automated evaluation on the real dataset and the interactive evaluation between humans and the dialogue system showed that the mental health support ability of the dialogue system was significantly improved, further confirming the high quality and practicality of the generated dataset.
Future Outlook
Using the generated data to train models for mental health support is a good choice. However, we noticed that the number of dialogue turns in the existing generated data is relatively short, and there is a certain gap in the strategy distribution compared with real consultation data. Therefore, adhering to the principle of benefiting users, we need to focus on the security performance of the model, including suicide intervention, handling of sensitive information, and avoidance of misinformation. We still have a long way to go.
The open-source Chinese mental health support model in this project is obtained through LoRA instruction fine-tuning of ChatGLM2-6B. The dataset expands real psychological mutual assistance Q&A into multi-turn mental health support dialogues, improving the performance of the general large language model in the field of mental health support and making it more suitable for long-term multi-turn dialogue application scenarios.
๐ฆ Installation
SMILE Method
Based on PsyQA, ChatGPT was used to generate one turn, and automated filtering was used: ensuring that the number of turns is no less than 5 and conforming to the dialogue format. The method is as follows:
Terminology Explanation
- client (visitor) == help-seeker
- counselor == supporter
Model Address
https://huggingface.co/qiuhuachuan/MeChat
๐ป Usage Examples
Basic Usage
The above quick start section shows the basic usage of the model, including environment configuration and running the interactive file.
Advanced Usage
In the model training section, we show how to convert data and use the generated data for model training.
Data Conversion
The data
directory contains all dialogues constructed using the smile
method. For details, please refer to the paper.
Execute the following script, and we will obtain 310,087 training samples.
convert_to_training_set.py
A training sample is as follows:
{
"instruction": "Now, you are playing the role of a professional psychological counselor. You have rich knowledge of psychology and mental health. You are good at using a variety of psychological counseling techniques, such as the principles of cognitive-behavioral therapy, motivational interviewing skills, and problem-oriented short-term therapy. Speak in a warm and friendly tone, showing empathy and a deep understanding of the client's feelings. Have a natural conversation with the client, avoiding responses that are too long or too short, and ensuring that the responses are smooth and similar to human conversations. Provide in-depth guidance and insights, using specific psychological concepts and examples to help the client explore their thoughts and feelings more deeply. Avoid didactic responses and focus more on empathy and respect for the client's feelings. Adjust your responses according to the client's feedback to ensure that they fit the client's situation and needs. Please generate a response for the following dialogue.\n\nDialogue:\nClient: I'm confused after the third year of high school and afraid before the college entrance examination. Can you give me some advice?\nCounselor: Seeing your question, I feel that you are very anxious. This state is easy to appear under the high pressure of high school. I want to say that I see your determination. This is something that many people don't have! The most important thing in the college entrance examination is not knowledge but mentality. It's the mentality of victory! Saying things like 'relax' or 'take it easy' is easy when you're not the one taking the exam. How can I relax when I have my own goals? I can't give up! Having goals is good, and what's missing is a plan! A plan for reasonable time allocation in the review process.\nClient: You're right. I'm really very anxious and do need to adjust my mentality. I also understand that mentality is very important in the college entrance examination, but how can I really have the mentality of victory?\nCounselor: First, you need to clarify your goals. Since you want to get into a bachelor's degree program, you need to prepare for it. Then, you need to formulate a reasonable review plan and arrange your daily study time and content according to your own situation. This can help you better control the entire review process and reduce anxiety.\nClient: I really don't have a reasonable review plan. I always feel that there's not enough time every day and don't know where to start. Can you give me some advice?\nCounselor: ",
"output": "Of course! You can start from the first year of high school and try the้ขๆตท strategy. Do more questions every day, which can improve your learning efficiency. At the same time, for the English subject, listening and memorizing more are very important. In terms of mathematics, physics, and chemistry, you can do some classic questions, especially those types that are often tested, and do the questions repeatedly."
}
๐ Documentation
Citation
If you use the data or code in this project, please cite it as follows:
@misc{qiu2023smile,
title={SMILE: Single-turn to Multi-turn Inclusive Language Expansion via ChatGPT for Mental Health Support},
author={Huachuan Qiu and Hongliang He and Shuai Zhang and Anqi Li and Zhenzhong Lan},
year={2023},
eprint={2305.00450},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
Disclaimer
Our mental health support dialogue robot (hereinafter referred to as the "robot") is designed to provide users with emotional support and mental health advice. However, the robot is not a healthcare professional and cannot replace the opinions, diagnoses, advice, or treatments of doctors, psychologists, or other professionals.
The advice and information provided by the robot are based on algorithms and machine learning techniques and may not be suitable for all users or all situations. Therefore, we recommend that users consult a doctor or other professional before using the robot to understand whether it is suitable for their use.
The robot does not guarantee the accuracy, completeness, timeliness, or applicability of the advice and information provided. Users shall bear all risks associated with using the robot's services. We shall not be liable for any consequences arising from users' use of the robot's services, including but not limited to any direct or indirect losses, injuries, mental illnesses, property losses, or any other damages.
We strongly recommend that users follow the following principles when using the robot's services:
- The robot is not a healthcare professional and cannot replace the opinions, diagnoses, advice, or treatments of doctors, psychologists, or other professionals. If users need professional medical or psychological counseling services, they should seek the help of doctors or other professionals.
- The advice and information provided by the robot are for reference only. Users should judge for themselves whether they are suitable for their own situations and needs. If users have any questions or uncertainties about the advice and information provided by the robot, they should consult the opinions of doctors or other professionals.
- Users should remain calm, rational, and objective and should not regard the advice and information provided by the robot as absolute truth or abandon their own judgment. If users have doubts or disagreements about the advice and information provided by the robot, they should stop using the robot's services and consult the opinions of doctors or other professionals.
- Users should abide by the robot's usage rules and service terms and shall not use the robot's services to engage in any illegal,่ฟ่ง, or rights-infringing activities.
- Users should protect their personal privacy and shall not disclose personal sensitive information or the privacy of others when using the robot's services.
- The data collected by the platform is used for academic research.
Finally, we reserve the right to modify, update, suspend, or terminate the robot's services at any time, and we also reserve the right to modify, update, or supplement this disclaimer. If users continue to use the robot's services, they are deemed to have agreed to all the contents and terms of this disclaimer.
๐ License
This project is licensed under the MIT license.
๐ Information Table
Property | Details |
---|---|
Model Type | Fine-tuned from ChatGLM2-6B LoRA |
Training Data | Approximately 55k multi-turn dialogue dataset generated by the SMILE method |
Evaluation Metrics | BLEU, ROUGE, METEOR, Perplexity |
Pipeline Tag | Text Generation |
Tags | Mental Health |




