scdong commited on
Commit
a33d471
Β·
1 Parent(s): f319223

Initial clean commit with hosted model

Browse files
Files changed (3) hide show
  1. .DS_Store +0 -0
  2. Dockerfile +6 -10
  3. README.md +46 -75
.DS_Store CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
 
Dockerfile CHANGED
@@ -1,21 +1,17 @@
1
- # Base image
2
  FROM python:3.10-slim
3
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
- # Install system dependencies
8
- RUN apt-get update && apt-get install -y git
9
-
10
  # Copy files
11
  COPY . .
12
 
13
- # Install Python dependencies
14
- RUN pip install --upgrade pip
15
- RUN pip install -r requirements.txt
16
 
17
- # Expose Streamlit default port
18
- EXPOSE 8501
19
 
20
  # Run the app
21
- CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.enableCORS=false"]
 
 
1
  FROM python:3.10-slim
2
 
3
  # Set working directory
4
  WORKDIR /app
5
 
 
 
 
6
  # Copy files
7
  COPY . .
8
 
9
+ # Install dependencies
10
+ RUN pip install --upgrade pip && \
11
+ pip install -r requirements.txt
12
 
13
+ # Expose Streamlit port
14
+ EXPOSE 7860
15
 
16
  # Run the app
17
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
README.md CHANGED
@@ -1,122 +1,93 @@
1
- ---
2
- title: Counselor Assistant
3
- emoji: πŸ‘€
4
- colorFrom: red
5
- colorTo: blue
6
- sdk: streamlit
7
- sdk_version: 1.44.1
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- ---
12
  # 🧠 Mental Health Counselor Assistant
13
 
14
- This project is a **counselor-facing AI assistant** designed to support mental health professionals by offering helpful suggestions in response to patient messages. It detects crisis and violent messages, generates supportive or informative suggestions, and provides logging and export features.
15
 
16
  ---
17
 
18
- ## πŸ“˜ How to use this app
19
 
20
- 1. Enter a message from a patient in the text box.
21
- 2. The app will generate helpful suggestions for how the counselor might reply.
22
- 3. If a safety risk is detected (e.g., crisis or violence), a safe response will be shown instead.
23
- 4. You can save the conversation history as a CSV file.
 
24
 
25
  ---
26
 
27
- ## 🧩 Key Features
28
-
29
- - βœ… Fine-tuned classifier (DistilBERT) for predicting intent (advice, question, validation, information)
30
- - πŸ” Streaming text generation using Flan-T5-XL
31
- - πŸ” Safety detection for crisis, violence, and toxicity
32
- - πŸ’‘ Suggestion prompts tailored to each response type
33
- - πŸ’Ύ Option to save conversation logs
34
- - πŸ“Έ Screenshots for walkthrough
35
-
36
- ---
37
 
38
- ## 🧠 Model Architecture
39
 
40
- - **Response Type Classifier**: `DistilBERT` fine-tuned on a labeled response dataset.
41
- - **Text Generator**: `google/flan-t5-xl` used to generate helpful, human-like counselor suggestions.
42
- - **Safety Filter**: Includes custom regex patterns and `Detoxify` toxicity detector.
43
 
44
  ---
45
 
46
- ## πŸ§ͺ Datasets Used
47
 
48
- - `counselchat-data.csv` – Labeled examples of counselor replies
49
- - `pair_data.csv` – Counselor-patient message pairs
50
- - `Kaggle_Mental_Health_Conversations_train.csv`
51
- - `distilbert_labeled_responses.csv` – Augmented training set
52
- - `cleaned_combined_mental_health_dataset.csv`
53
 
54
  ---
55
 
56
- ## πŸ“ Project Structure
57
 
58
  ```bash
59
- counselor-assistant/
60
- β”œβ”€β”€ app.py # Main Streamlit app
61
- β”œβ”€β”€ Dockerfile # Containerization for deployment
62
- β”œβ”€β”€ requirements.txt # Python dependencies
63
- β”œβ”€β”€ pedal.yaml # Optional: Pedal config
64
- β”œβ”€β”€ datasets/ # Training + testing datasets
65
- β”œβ”€β”€ models/ # Fine-tuned model + tokenizer
66
- β”œβ”€β”€ notebooks/ # Data prep + training notebooks
67
- β”œβ”€β”€ logs/ # Saved chat logs
68
- β”œβ”€β”€ screenshots/ # App walkthrough examples
69
- β”œβ”€β”€ cache/ # Prompt-response cache
70
- └── alert/ # Alert logs (for flagged inputs)
71
  ```
72
 
73
  ---
74
 
75
- ## 🐳 Docker Deployment
76
-
77
- To build and run the app locally:
78
 
79
  ```bash
 
80
  docker build -t counselor-assistant .
 
 
81
  docker run -p 7860:7860 counselor-assistant
82
  ```
83
 
84
- Then navigate to `http://localhost:7860` in your browser.
85
 
86
  ---
87
 
88
- ## ☁️ Hugging Face Deployment
89
-
90
- You can deploy to [Hugging Face Spaces](https://huggingface.co/spaces/) by:
91
 
92
- 1. Adding this repo to a Space with SDK = `streamlit`
93
- 2. Uploading the model folder to the Space (or hosting it via Hugging Face Hub)
94
- 3. Pushing your app via `git push`
 
 
95
 
96
  ---
97
 
98
- ## πŸ“Έ Screenshots
99
-
100
- ### πŸ’¬ Classifier Prediction + Suggestions
101
- ![example1](screenshots/example1.png)
102
-
103
- ### 🚨 Safe Response for Crisis Input
104
- ![example2](screenshots/example2.png)
105
 
106
- ### 🧠 Multiple Suggestions
107
- ![example3](screenshots/example3.png)
108
 
109
- ### πŸ’Ύ Logging the Conversation
110
- ![example4](screenshots/example4.png)
111
 
112
  ---
113
 
114
- ## πŸ“¦ Requirements
115
-
116
- Install dependencies:
117
 
118
  ```bash
119
- pip install -r requirements.txt
 
 
 
 
 
120
  ```
121
 
 
 
 
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # 🧠 Mental Health Counselor Assistant
2
 
3
+ This app helps mental health counselors generate helpful, informed, and compassionate suggestions based on patient messages. It classifies the message intent and offers guidance for how a counselor might respond, with built-in safety checks for crisis or violent content.
4
 
5
  ---
6
 
7
+ ## πŸ’‘ Features
8
 
9
+ - βœ… Response type classification (advice, validation, information, question)
10
+ - πŸ’¬ LLM-generated counselor suggestions using `google/flan-t5-xl`
11
+ - πŸ›‘οΈ Built-in safety detection for crisis and toxic content
12
+ - πŸ’Ύ Conversation history logging and export
13
+ - 🌐 Web-based Streamlit interface
14
 
15
  ---
16
 
17
+ ## πŸ“¦ Hosted Model
 
 
 
 
 
 
 
 
 
18
 
19
+ This app uses a fine-tuned classification model hosted at:
20
 
21
+ ➑️ [`scdong/distilbert-response-type`](https://huggingface.co/scdong/distilbert-response-type)
 
 
22
 
23
  ---
24
 
25
+ ## πŸš€ How to Use
26
 
27
+ 1. Enter a patient's message in the chat box.
28
+ 2. The app detects safety concerns (e.g. suicidal, violent, or toxic content).
29
+ 3. If safe, it classifies the message and generates counselor-style suggestions.
30
+ 4. You can export the session log as a CSV file.
 
31
 
32
  ---
33
 
34
+ ## πŸ–₯️ Running Locally
35
 
36
  ```bash
37
+ # Install dependencies
38
+ pip install -r requirements.txt
39
+
40
+ # Run the app
41
+ streamlit run app.py
 
 
 
 
 
 
 
42
  ```
43
 
44
  ---
45
 
46
+ ## 🐳 Docker (optional)
 
 
47
 
48
  ```bash
49
+ # Build Docker image
50
  docker build -t counselor-assistant .
51
+
52
+ # Run it
53
  docker run -p 7860:7860 counselor-assistant
54
  ```
55
 
56
+ Then go to `http://localhost:7860` in your browser.
57
 
58
  ---
59
 
60
+ ## 🧠 Example Use Case
 
 
61
 
62
+ > **Patient:** I feel like I’m not good enough, no matter how hard I try.
63
+ > **Suggestions:**
64
+ > - You're doing more than enough β€” even if it doesn't feel like it right now.
65
+ > - Try to be as kind to yourself as you would to a close friend.
66
+ > - Even small steps forward count. You're showing up, and that matters.
67
 
68
  ---
69
 
70
+ ## πŸ›‘ Crisis Handling
 
 
 
 
 
 
71
 
72
+ If the input includes high-risk language (e.g., "I want to kill myself"), the app immediately responds with:
 
73
 
74
+ > _"I'm really sorry you're feeling this way. You're not alone. Please consider calling 988 or speaking with a mental health professional right away."_
 
75
 
76
  ---
77
 
78
+ ## πŸ“ File Structure
 
 
79
 
80
  ```bash
81
+ .
82
+ β”œβ”€β”€ app.py # Main Streamlit app
83
+ β”œβ”€β”€ requirements.txt # Python dependencies
84
+ β”œβ”€β”€ Dockerfile # (Optional) Docker setup
85
+ β”œβ”€β”€ cache.json # Prompt/response cache
86
+ β”œβ”€β”€ README.md # This file
87
  ```
88
 
89
+ ---
90
+
91
+ ## 🀝 License
92
 
93
+ MIT License.