File size: 3,188 Bytes
5421d6e
 
 
 
 
 
d8294c6
5421d6e
 
 
 
fe336db
 
2f1982d
 
 
 
 
 
 
 
 
 
 
fe336db
bd30f7c
fe336db
 
 
 
 
2f1982d
 
 
 
 
 
 
fe336db
 
2f1982d
fe336db
 
2f1982d
fe336db
 
2f1982d
 
 
fe336db
 
2f1982d
fe336db
 
bd30f7c
 
fe336db
 
2f1982d
 
fe336db
2f1982d
 
 
 
 
 
 
fe336db
2f1982d
 
bd30f7c
 
 
2f1982d
fe336db
 
2f1982d
fe336db
 
 
2f1982d
fe336db
 
 
 
 
2f1982d
bd30f7c
fe336db
 
2f1982d
 
fe336db
bd30f7c
fe336db
bd30f7c
fe336db
4e7a5e8
2f1982d
 
 
fe336db
bd30f7c
 
fe336db
bd30f7c
2f1982d
 
 
 
bd30f7c
2f1982d
bd30f7c
 
 
4e7a5e8
bd30f7c
2f1982d
 
d8294c6
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
title: Mental Health Counselor Assistant
emoji: 🧠
colorFrom: indigo
colorTo: green
sdk: streamlit
sdk_version: 1.44.1
app_file: app.py
pinned: false
license: mit
---
# 🧠 Mental Health Counselor Assistant

**Mental Health Counselor Assistant** is an AI-powered Streamlit application hosted on [Hugging Face Spaces](https://huggingface.co/spaces/scdong/mental_health_chatbot). It assists mental health professionals by classifying user inputs and generating supportive counselor-style responses using large language models (LLMs) like **Flan-T5** and **Mistral-7B**.

---

## ⚑ Quick Start

The app uses `google/flan-t5-base` for fast, low-latency response generation.

> πŸ“ `app.py` is optimized for **speed**, using only `/flan-t5-base`.  
> While the results may not be as expressive as other models, it loads and responds much faster.  
> For higher quality but slower results, try the other two apps included.

---

## πŸ“¦ Project Structure

```
mental_health_chatbot/
β”œβ”€β”€ app.py                                # Fast demo with Flan-T5 only (used on Hugging Face)
β”œβ”€β”€ app_use_Mistral-7B.py                 # Local LLM with quantized Mistral-7B via llama.cpp
β”œβ”€β”€ app_with_FlanT5_FlanAlpacaGPT4_FlanUL2.py  # Hosted Hugging Face models (slower, richer output)
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ README.md
β”œβ”€β”€ LICENSE

β”œβ”€β”€ dataset/
β”‚   └── Kaggle_Mental_Health_Conversations_train.csv

β”œβ”€β”€ utils/
β”‚   └── helper_functions.py

β”œβ”€β”€ notebooks/
β”‚   β”œβ”€β”€ Flan-T5_on_Kaggle_Dataset.ipynb
β”‚   β”œβ”€β”€ Mistral-7B_on_Kaggle_Dataset.ipynb
β”‚   └── ML_on_Kaggle_Dataset.ipynb

└── log/
    └── chat_log_2025-04-11_05-31-25.csv
```

---

## πŸ’‘ Features

- πŸ” **Intent Classification** (XGBoost):  
  Tags inputs as `advice`, `validation`, `information`, or `question`.

- πŸ€– **LLM-Based Suggestion Generation**  
  Choose from:
  - `google/flan-t5-base` (fastest)
  - `declare-lab/flan-alpaca-gpt4-xl`
  - `google/flan-ul2`
  - `mistralai/Mistral-7B-Instruct-v0.1` (local only)
  

- πŸ’Ύ **Session Logging**  
  Automatically saves conversation history to CSV in `/log`.

---

## πŸš€ Run Locally (Optional)

```bash
git clone https://huggingface.co/spaces/scdong/mental_health_chatbot
cd mental_health_chatbot

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

streamlit run app.py
```

For the Mistral or full-model version:

```bash
streamlit run app_use_Mistral-7B.py
# or
streamlit run app_with_FlanT5_FlanAlpacaGPT4_FlanUL2.py
```

---

## πŸ““ Dataset

This project uses:
- 🧾 `Kaggle_Mental_Health_Conversations_train.csv`  
  A labeled dataset of user statements and counselor responses used for training and testing classification.

---

## πŸ§‘β€βš•οΈ Intended Use

This tool is designed for:
- Mental health professionals exploring AI assistance
- NLP researchers and students
- Developers building mental health chatbot prototypes

> ⚠️ **Not a substitute for professional mental health advice.**

---

## πŸ“œ License

This project is licensed under the **MIT License**.  
See the `LICENSE` file for more details.
```