Spaces:
Sleeping
Sleeping
git push origin main
Browse filesInitial commit of mental_health_chatbot app
- README.md +53 -105
- utils/__pycache__/helper_functions.cpython-310.pyc +0 -0
README.md
CHANGED
@@ -4,15 +4,24 @@ emoji: π§
|
|
4 |
colorFrom: indigo
|
5 |
colorTo: green
|
6 |
sdk: streamlit
|
7 |
-
sdk_version: 1.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
---
|
12 |
-
|
13 |
# π§ Mental Health Counselor Assistant
|
14 |
|
15 |
-
**Mental Health Counselor Assistant** is an AI-powered Streamlit application
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
---
|
18 |
|
@@ -20,154 +29,93 @@ license: mit
|
|
20 |
|
21 |
```
|
22 |
mental_health_chatbot/
|
23 |
-
βββ app.py #
|
24 |
-
βββ app_use_Mistral-7B.py # Local Mistral-7B
|
25 |
-
βββ app_with_FlanT5_FlanAlpacaGPT4_FlanUL2.py #
|
26 |
-
βββ requirements.txt
|
27 |
-
βββ Dockerfile
|
28 |
-
βββ README.md
|
29 |
-
βββ LICENSE
|
30 |
|
31 |
βββ dataset/
|
32 |
-
β βββ Kaggle_Mental_Health_Conversations_train.csv
|
33 |
|
34 |
βββ utils/
|
35 |
-
β βββ helper_functions.py
|
36 |
|
37 |
βββ notebooks/
|
38 |
-
β βββ Flan-T5_on_Kaggle_Dataset.ipynb
|
39 |
-
β βββ Mistral-7B_on_Kaggle_Dataset.ipynb
|
40 |
-
β βββ ML_on_Kaggle_Dataset.ipynb
|
41 |
|
42 |
βββ log/
|
43 |
-
βββ chat_log_2025-04-11_05-31-25.csv
|
44 |
```
|
45 |
|
46 |
---
|
47 |
|
48 |
## π‘ Features
|
49 |
|
50 |
-
- π **
|
51 |
-
|
52 |
-
- `advice`
|
53 |
-
- `validation`
|
54 |
-
- `information`
|
55 |
-
- `question`
|
56 |
|
57 |
-
-
|
58 |
-
|
59 |
-
-
|
60 |
-
-
|
61 |
-
-
|
|
|
|
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
- π― **Primed & Prompt-Engineered Outputs**
|
66 |
-
Uses few-shot prompt design to ensure counselor-style tone, empathy, and helpfulness.
|
67 |
-
|
68 |
-
- π§ͺ **Modular & Experiment-Ready**
|
69 |
-
Jupyter notebooks for training, testing, and benchmarking models.
|
70 |
-
|
71 |
-
- πΎ **Conversation Logging**
|
72 |
-
Auto-saves counselor-patient interactions to `/log` for post-session review.
|
73 |
|
74 |
---
|
75 |
|
76 |
-
## π
|
77 |
-
|
78 |
-
### 1. Clone the Repository
|
79 |
|
80 |
```bash
|
81 |
-
git clone https://
|
82 |
cd mental_health_chatbot
|
83 |
-
```
|
84 |
-
|
85 |
-
### 2. Set Up the Environment
|
86 |
|
87 |
-
```bash
|
88 |
python -m venv venv
|
89 |
-
source venv/bin/activate
|
90 |
pip install -r requirements.txt
|
91 |
-
```
|
92 |
-
|
93 |
-
### 3. Run the App
|
94 |
|
95 |
-
#### Run fast, default version (Flan-T5):
|
96 |
-
|
97 |
-
```bash
|
98 |
streamlit run app.py
|
99 |
```
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
```bash
|
104 |
-
streamlit run app_with_FlanT5_FlanAlpacaGPT4_FlanUL2.py
|
105 |
-
```
|
106 |
-
|
107 |
-
#### Run local Mistral-7B (with `llama-cpp-python`):
|
108 |
|
109 |
```bash
|
110 |
streamlit run app_use_Mistral-7B.py
|
111 |
-
|
112 |
-
|
113 |
-
---
|
114 |
-
|
115 |
-
## π³ Docker (Optional)
|
116 |
-
|
117 |
-
To build and deploy with Docker:
|
118 |
-
|
119 |
-
```bash
|
120 |
-
docker build -t counselor-assistant .
|
121 |
-
docker run -p 8501:8501 counselor-assistant
|
122 |
```
|
123 |
|
124 |
---
|
125 |
|
126 |
## π Dataset
|
127 |
|
128 |
-
This project uses
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
---
|
133 |
-
|
134 |
-
## π Notebooks
|
135 |
-
|
136 |
-
Explore or reproduce training and benchmarking in:
|
137 |
-
|
138 |
-
- `ML_on_Kaggle_Dataset.ipynb`: Training XGBoost and TF-IDF classifier
|
139 |
-
- `Flan-T5_on_Kaggle_Dataset.ipynb`: Hosted inference test
|
140 |
-
- `Mistral-7B_on_Kaggle_Dataset.ipynb`: Local quantized LLM
|
141 |
-
|
142 |
-
---
|
143 |
-
|
144 |
-
## π Log Files
|
145 |
-
|
146 |
-
Each chat session is saved with timestamp in the `log/` directory, e.g.:
|
147 |
-
|
148 |
-
```
|
149 |
-
log/chat_log_2025-04-11_05-31-25.csv
|
150 |
-
```
|
151 |
-
|
152 |
-
These CSVs include patient messages, predicted intent, AI-generated counselor suggestions, and classification confidence.
|
153 |
|
154 |
---
|
155 |
|
156 |
## π§ββοΈ Intended Use
|
157 |
|
158 |
-
This tool is
|
159 |
-
|
160 |
-
-
|
161 |
-
-
|
162 |
-
- Developers building therapeutic chatbot systems
|
163 |
|
164 |
-
β οΈ
|
165 |
|
166 |
---
|
167 |
|
168 |
## π License
|
169 |
|
170 |
-
|
171 |
-
See
|
172 |
-
|
173 |
-
---
|
|
|
4 |
colorFrom: indigo
|
5 |
colorTo: green
|
6 |
sdk: streamlit
|
7 |
+
sdk_version: 1.32.2
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
---
|
|
|
12 |
# π§ Mental Health Counselor Assistant
|
13 |
|
14 |
+
**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**.
|
15 |
+
|
16 |
+
---
|
17 |
+
|
18 |
+
## β‘ Quick Start
|
19 |
+
|
20 |
+
The app uses `google/flan-t5-base` for fast, low-latency response generation.
|
21 |
+
|
22 |
+
> π `app.py` is optimized for **speed**, using only `/flan-t5-base`.
|
23 |
+
> While the results may not be as expressive as other models, it loads and responds much faster.
|
24 |
+
> For higher quality but slower results, try the other two apps included.
|
25 |
|
26 |
---
|
27 |
|
|
|
29 |
|
30 |
```
|
31 |
mental_health_chatbot/
|
32 |
+
βββ app.py # Fast demo with Flan-T5 only (used on Hugging Face)
|
33 |
+
βββ app_use_Mistral-7B.py # Local LLM with quantized Mistral-7B via llama.cpp
|
34 |
+
βββ app_with_FlanT5_FlanAlpacaGPT4_FlanUL2.py # Hosted Hugging Face models (slower, richer output)
|
35 |
+
βββ requirements.txt
|
36 |
+
βββ Dockerfile
|
37 |
+
βββ README.md
|
38 |
+
βββ LICENSE
|
39 |
|
40 |
βββ dataset/
|
41 |
+
β βββ Kaggle_Mental_Health_Conversations_train.csv
|
42 |
|
43 |
βββ utils/
|
44 |
+
β βββ helper_functions.py
|
45 |
|
46 |
βββ notebooks/
|
47 |
+
β βββ Flan-T5_on_Kaggle_Dataset.ipynb
|
48 |
+
β βββ Mistral-7B_on_Kaggle_Dataset.ipynb
|
49 |
+
β βββ ML_on_Kaggle_Dataset.ipynb
|
50 |
|
51 |
βββ log/
|
52 |
+
βββ chat_log_2025-04-11_05-31-25.csv
|
53 |
```
|
54 |
|
55 |
---
|
56 |
|
57 |
## π‘ Features
|
58 |
|
59 |
+
- π **Intent Classification** (XGBoost):
|
60 |
+
Tags inputs as `advice`, `validation`, `information`, or `question`.
|
|
|
|
|
|
|
|
|
61 |
|
62 |
+
- π€ **LLM-Based Suggestion Generation**
|
63 |
+
Choose from:
|
64 |
+
- `google/flan-t5-base` (fastest)
|
65 |
+
- `declare-lab/flan-alpaca-gpt4-xl`
|
66 |
+
- `google/flan-ul2`
|
67 |
+
- `mistralai/Mistral-7B-Instruct-v0.1` (local only)
|
68 |
+
|
69 |
|
70 |
+
- πΎ **Session Logging**
|
71 |
+
Automatically saves conversation history to CSV in `/log`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
---
|
74 |
|
75 |
+
## π Run Locally (Optional)
|
|
|
|
|
76 |
|
77 |
```bash
|
78 |
+
git clone https://huggingface.co/spaces/scdong/mental_health_chatbot
|
79 |
cd mental_health_chatbot
|
|
|
|
|
|
|
80 |
|
|
|
81 |
python -m venv venv
|
82 |
+
source venv/bin/activate
|
83 |
pip install -r requirements.txt
|
|
|
|
|
|
|
84 |
|
|
|
|
|
|
|
85 |
streamlit run app.py
|
86 |
```
|
87 |
|
88 |
+
For the Mistral or full-model version:
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
```bash
|
91 |
streamlit run app_use_Mistral-7B.py
|
92 |
+
# or
|
93 |
+
streamlit run app_with_FlanT5_FlanAlpacaGPT4_FlanUL2.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
```
|
95 |
|
96 |
---
|
97 |
|
98 |
## π Dataset
|
99 |
|
100 |
+
This project uses:
|
101 |
+
- π§Ύ `Kaggle_Mental_Health_Conversations_train.csv`
|
102 |
+
A labeled dataset of user statements and counselor responses used for training and testing classification.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
---
|
105 |
|
106 |
## π§ββοΈ Intended Use
|
107 |
|
108 |
+
This tool is designed for:
|
109 |
+
- Mental health professionals exploring AI assistance
|
110 |
+
- NLP researchers and students
|
111 |
+
- Developers building mental health chatbot prototypes
|
|
|
112 |
|
113 |
+
> β οΈ **Not a substitute for professional mental health advice.**
|
114 |
|
115 |
---
|
116 |
|
117 |
## π License
|
118 |
|
119 |
+
This project is licensed under the **MIT License**.
|
120 |
+
See the `LICENSE` file for more details.
|
121 |
+
```
|
|
utils/__pycache__/helper_functions.cpython-310.pyc
CHANGED
Binary files a/utils/__pycache__/helper_functions.cpython-310.pyc and b/utils/__pycache__/helper_functions.cpython-310.pyc differ
|
|