scdong commited on
Commit
2f1982d
Β·
1 Parent(s): aab6f80

git push origin main

Browse files

Initial commit of mental_health_chatbot app

README.md CHANGED
@@ -4,15 +4,24 @@ emoji: 🧠
4
  colorFrom: indigo
5
  colorTo: green
6
  sdk: streamlit
7
- sdk_version: 1.44.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 designed to help therapists and mental health professionals respond more effectively to patients. It combines machine learning for **intent classification** with powerful large language models (LLMs) like **Flan-T5**, **Mistral-7B**, and **Flan-Alpaca-GPT4** to generate emotionally intelligent, context-aware suggestions.
 
 
 
 
 
 
 
 
 
 
16
 
17
  ---
18
 
@@ -20,154 +29,93 @@ license: mit
20
 
21
  ```
22
  mental_health_chatbot/
23
- β”œβ”€β”€ app.py # Main app (fast Flan-T5 only)
24
- β”œβ”€β”€ app_use_Mistral-7B.py # Local Mistral-7B (quantized .gguf)
25
- β”œβ”€β”€ app_with_FlanT5_FlanAlpacaGPT4_FlanUL2.py # App with selectable hosted Hugging Face LLMs
26
- β”œβ”€β”€ requirements.txt # Python dependencies
27
- β”œβ”€β”€ Dockerfile # For containerized deployment
28
- β”œβ”€β”€ README.md # You're here!
29
- β”œβ”€β”€ LICENSE # Open-source license
30
 
31
  β”œβ”€β”€ dataset/
32
- β”‚ └── Kaggle_Mental_Health_Conversations_train.csv # Training dataset
33
 
34
  β”œβ”€β”€ utils/
35
- β”‚ └── helper_functions.py # Preprocessing and helpers
36
 
37
  β”œβ”€β”€ notebooks/
38
- β”‚ β”œβ”€β”€ Flan-T5_on_Kaggle_Dataset.ipynb # Inference experiments
39
- β”‚ β”œβ”€β”€ Mistral-7B_on_Kaggle_Dataset.ipynb # Local LLM generation
40
- β”‚ └── ML_on_Kaggle_Dataset.ipynb # Model training and eval
41
 
42
  └── log/
43
- └── chat_log_2025-04-11_05-31-25.csv # Example saved conversation log
44
  ```
45
 
46
  ---
47
 
48
  ## πŸ’‘ Features
49
 
50
- - πŸ” **Response Type Classification**
51
- Predicts one of four counseling intents from patient input:
52
- - `advice`
53
- - `validation`
54
- - `information`
55
- - `question`
56
 
57
- - 🧠 **LLM-Powered Reply Generation**
58
- Generates suggestions using:
59
- - βœ… `google/flan-t5-base` (fast, hosted)
60
- - βœ… `mistralai/Mistral-7B-Instruct-v0.1` (runs locally via `llama.cpp`)
61
- - βœ… `declare-lab/flan-alpaca-gpt4-xl` and `flan-ul2` (hosted via Hugging Face)
 
 
62
 
63
- ⚠️ **Note**: LLM response times may vary. Hosted models are slower but provide higher-quality, human-like responses.
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
- ## πŸš€ Getting Started
77
-
78
- ### 1. Clone the Repository
79
 
80
  ```bash
81
- git clone https://github.com/your-username/mental_health_chatbot.git
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 # Windows: venv\Scripts\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
- #### Run version with all Hugging Face LLMs:
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 the Kaggle dataset:
129
- **Kaggle_Mental_Health_Conversations_train.csv**
130
- Located in the `dataset/` folder, it contains real user mental health exchanges labeled with response types.
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 built for **prototyping** and **research**. Potential users include:
159
-
160
- - Mental health professionals exploring AI support
161
- - Researchers in NLP and digital health
162
- - Developers building therapeutic chatbot systems
163
 
164
- ⚠️ This tool is **not a replacement for human therapy**.
165
 
166
  ---
167
 
168
  ## πŸ“œ License
169
 
170
- Licensed under the **MIT License**.
171
- See [`LICENSE`](./LICENSE) for full terms.
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