Spaces:
Sleeping
Sleeping
ASledziewska
commited on
Commit
•
1830956
1
Parent(s):
bac2b7b
add updated files
Browse files- .DS_Store +0 -0
- Chromadb_storage.py +63 -0
- app.py +141 -82
- data/adhd_questions.txt +30 -0
- data/anxiety_questions.txt +30 -0
- data.csv → data/data.csv +0 -0
- data/depression_questions.txt +30 -0
- llm_response_generator.py +1 -1
- q_learning_chatbot.py +1 -1
- xgb_mental_health.py +1 -1
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
Chromadb_storage.py
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import nltk
|
2 |
+
from nltk.tokenize import word_tokenize
|
3 |
+
from langchain_community.document_loaders import TextLoader
|
4 |
+
from langchain_community.embeddings.sentence_transformer import (
|
5 |
+
SentenceTransformerEmbeddings,
|
6 |
+
)
|
7 |
+
from langchain_community.vectorstores import Chroma
|
8 |
+
from langchain_text_splitters import CharacterTextSplitter
|
9 |
+
|
10 |
+
# Download NLTK data for tokenization
|
11 |
+
nltk.download('punkt')
|
12 |
+
import os
|
13 |
+
global db
|
14 |
+
class QuestionRetriever:
|
15 |
+
|
16 |
+
def load_documents(self,file_name):
|
17 |
+
data_directory = "data/"
|
18 |
+
file_path = os.path.join(data_directory, file_name)
|
19 |
+
loader = TextLoader(file_path)
|
20 |
+
documents = loader.load()
|
21 |
+
return documents
|
22 |
+
|
23 |
+
def store_data_in_vector_db(self,documents):
|
24 |
+
# global db
|
25 |
+
text_splitter = CharacterTextSplitter(chunk_size=100, chunk_overlap=0,separator="\n")
|
26 |
+
docs = text_splitter.split_documents(documents)
|
27 |
+
# create the open-source embedding function
|
28 |
+
embedding_function = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
|
29 |
+
# print(docs)
|
30 |
+
# load it into Chroma
|
31 |
+
db = Chroma.from_documents(docs, embedding_function)
|
32 |
+
return db
|
33 |
+
|
34 |
+
def get_response(self, user_query, predicted_mental_category):
|
35 |
+
if predicted_mental_category == "depression":
|
36 |
+
documents=self.load_documents("depression_questions.txt")
|
37 |
+
|
38 |
+
elif predicted_mental_category == "adhd":
|
39 |
+
documents=self.load_documents("adhd_questions.txt")
|
40 |
+
|
41 |
+
elif predicted_mental_category == "anxiety":
|
42 |
+
documents=self.load_documents("anxiety_questions.txt")
|
43 |
+
|
44 |
+
else:
|
45 |
+
print("Sorry, allowed predicted_mental_category is ['depresison', 'adhd', 'anxiety'].")
|
46 |
+
return
|
47 |
+
db=self.store_data_in_vector_db(documents)
|
48 |
+
|
49 |
+
docs = db.similarity_search(user_query)
|
50 |
+
most_similar_question = docs[0].page_content.split("\n")[0] # Extract the first question
|
51 |
+
if user_query==most_similar_question:
|
52 |
+
most_similar_question=docs[1].page_content.split("\n")[0]
|
53 |
+
|
54 |
+
print(most_similar_question)
|
55 |
+
return most_similar_question
|
56 |
+
|
57 |
+
if __name__ == "__main__":
|
58 |
+
model = QuestionRetriever()
|
59 |
+
user_input = input("User: ")
|
60 |
+
|
61 |
+
predicted_mental_condition = "depression"
|
62 |
+
response = model.get_response(user_input, predicted_mental_condition)
|
63 |
+
print("Chatbot:", response)
|
app.py
CHANGED
@@ -1,32 +1,38 @@
|
|
1 |
-
|
2 |
-
import os
|
3 |
import pandas as pd
|
4 |
import streamlit as st
|
5 |
from q_learning_chatbot import QLearningChatbot
|
6 |
from xgb_mental_health import MentalHealthClassifier
|
7 |
-
from bm25_retreive_question import QuestionRetriever
|
|
|
8 |
from llm_response_generator import LLLResponseGenerator
|
9 |
-
|
10 |
# Streamlit UI
|
11 |
st.title("FOMO Fix - RL-based Mental Health Assistant")
|
12 |
|
13 |
# Define states and actions
|
14 |
-
states = [
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
# Initialize Q-learning chatbot and mental health classifier
|
18 |
chatbot = QLearningChatbot(states, actions)
|
19 |
|
20 |
# Initialize MentalHealthClassifier
|
21 |
-
data_path = "data.csv"
|
|
|
22 |
tokenizer_model_name = "nlptown/bert-base-multilingual-uncased-sentiment"
|
23 |
-
mental_classifier_model_path =
|
24 |
mental_classifier = MentalHealthClassifier(data_path, mental_classifier_model_path)
|
25 |
|
26 |
|
27 |
# Function to display Q-table
|
28 |
def display_q_table(q_values, states, actions):
|
29 |
-
q_table_dict = {
|
30 |
for i, action in enumerate(actions):
|
31 |
q_table_dict[action] = q_values[:, i]
|
32 |
|
@@ -35,100 +41,153 @@ def display_q_table(q_values, states, actions):
|
|
35 |
|
36 |
|
37 |
# Initialize memory
|
38 |
-
if
|
39 |
st.session_state.entered_text = []
|
40 |
-
if
|
41 |
st.session_state.entered_mood = []
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
# Collect user input
|
44 |
-
user_message = st.
|
45 |
|
46 |
# Take user input
|
47 |
if user_message:
|
48 |
st.session_state.entered_text.append(user_message)
|
49 |
|
|
|
|
|
|
|
50 |
# Detect mental condition
|
51 |
-
mental_classifier.initialize_tokenizer(tokenizer_model_name)
|
52 |
-
mental_classifier.preprocess_data()
|
53 |
-
predicted_mental_category = mental_classifier.predict_category(user_message)
|
54 |
-
print("Predicted mental health condition:", predicted_mental_category)
|
55 |
-
# st.subheader("🛑 " + f"{predicted_mental_category.capitalize()}")
|
56 |
-
|
57 |
-
# Retrieve question
|
58 |
-
retriever = QuestionRetriever()
|
59 |
-
question = retriever.get_response(user_message, predicted_mental_category)
|
60 |
-
# st.write(question)
|
61 |
-
|
62 |
-
# Detect sentiment
|
63 |
-
user_sentiment = chatbot.detect_sentiment(user_message)
|
64 |
-
# Update mood history / moode_trend
|
65 |
-
chatbot.update_mood_history()
|
66 |
-
mood_trend = chatbot.check_mood_trend()
|
67 |
-
|
68 |
-
# Define rewards
|
69 |
-
if user_sentiment in ["Positive", "Moderately Positive"]:
|
70 |
-
if mood_trend == "increased":
|
71 |
-
reward = +0.8
|
72 |
-
else: # decresed
|
73 |
-
reward = -0.3
|
74 |
-
|
75 |
-
else:
|
76 |
-
if mood_trend == "increased":
|
77 |
-
reward = +1
|
78 |
-
else:
|
79 |
-
reward = -1
|
80 |
-
|
81 |
-
print(f"mood_trend - sentiment - reward: {mood_trend} - {user_sentiment} - 🛑{reward}🛑 -- (a)")
|
82 |
-
|
83 |
-
# Update Q-values
|
84 |
-
chatbot.update_q_values(user_sentiment, chatbot.actions[0], reward, user_sentiment)
|
85 |
-
|
86 |
-
# Get recommended action based on the updated Q-values
|
87 |
-
ai_tone = chatbot.get_action(user_sentiment)
|
88 |
-
print(ai_tone)
|
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 |
-
prompt_template=template,
|
115 |
-
context=context,
|
116 |
-
ai_tone=ai_tone,
|
117 |
-
questionnaire=predicted_mental_category,
|
118 |
-
user_text=user_message,
|
119 |
-
temperature=temperature,
|
120 |
-
max_length=max_length,
|
121 |
)
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
-
st.
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
st.subheader("Behind the Scence - What AI is doing:")
|
128 |
-
st.write(
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
st.write(f"- AI Tone: {ai_tone.capitalize()}")
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
132 |
|
133 |
# Display results
|
134 |
# st.subheader(f"{user_sentiment.capitalize()}")
|
|
|
|
|
|
|
1 |
import pandas as pd
|
2 |
import streamlit as st
|
3 |
from q_learning_chatbot import QLearningChatbot
|
4 |
from xgb_mental_health import MentalHealthClassifier
|
5 |
+
from bm25_retreive_question import QuestionRetriever as QuestionRetriever_bm25
|
6 |
+
from Chromadb_storage_JyotiNigam import QuestionRetriever as QuestionRetriever_chromaDB
|
7 |
from llm_response_generator import LLLResponseGenerator
|
8 |
+
import os
|
9 |
# Streamlit UI
|
10 |
st.title("FOMO Fix - RL-based Mental Health Assistant")
|
11 |
|
12 |
# Define states and actions
|
13 |
+
states = [
|
14 |
+
"Negative",
|
15 |
+
"Moderately Negative",
|
16 |
+
"Neutral",
|
17 |
+
"Moderately Positive",
|
18 |
+
"Positive",
|
19 |
+
]
|
20 |
+
actions = ["encouragement", "empathy", "spiritual"]
|
21 |
|
22 |
# Initialize Q-learning chatbot and mental health classifier
|
23 |
chatbot = QLearningChatbot(states, actions)
|
24 |
|
25 |
# Initialize MentalHealthClassifier
|
26 |
+
# data_path = "/Users/jaelinlee/Documents/projects/fomo/input/data.csv"
|
27 |
+
data_path = "data/data.csv"
|
28 |
tokenizer_model_name = "nlptown/bert-base-multilingual-uncased-sentiment"
|
29 |
+
mental_classifier_model_path = "app/mental_health_model.pkl"
|
30 |
mental_classifier = MentalHealthClassifier(data_path, mental_classifier_model_path)
|
31 |
|
32 |
|
33 |
# Function to display Q-table
|
34 |
def display_q_table(q_values, states, actions):
|
35 |
+
q_table_dict = {"State": states}
|
36 |
for i, action in enumerate(actions):
|
37 |
q_table_dict[action] = q_values[:, i]
|
38 |
|
|
|
41 |
|
42 |
|
43 |
# Initialize memory
|
44 |
+
if "entered_text" not in st.session_state:
|
45 |
st.session_state.entered_text = []
|
46 |
+
if "entered_mood" not in st.session_state:
|
47 |
st.session_state.entered_mood = []
|
48 |
|
49 |
+
if "messages" not in st.session_state:
|
50 |
+
st.session_state.messages = []
|
51 |
+
|
52 |
+
# Select Question Retriever
|
53 |
+
selected_retriever_option = st.sidebar.selectbox(
|
54 |
+
"Choose Question Retriever", ("BM25", "ChromaDB")
|
55 |
+
)
|
56 |
+
if selected_retriever_option == "BM25":
|
57 |
+
retriever = QuestionRetriever_bm25()
|
58 |
+
if selected_retriever_option == "ChromaDB":
|
59 |
+
retriever = QuestionRetriever_chromaDB()
|
60 |
+
|
61 |
+
for message in st.session_state.messages:
|
62 |
+
with st.chat_message(message.get("role")):
|
63 |
+
st.write(message.get("content"))
|
64 |
+
|
65 |
# Collect user input
|
66 |
+
user_message = st.chat_input("Type your message here:")
|
67 |
|
68 |
# Take user input
|
69 |
if user_message:
|
70 |
st.session_state.entered_text.append(user_message)
|
71 |
|
72 |
+
st.session_state.messages.append({"role": "user", "content": user_message})
|
73 |
+
with st.chat_message("user"):
|
74 |
+
st.write(user_message)
|
75 |
# Detect mental condition
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
+
with st.spinner("Processing..."):
|
78 |
+
mental_classifier.initialize_tokenizer(tokenizer_model_name)
|
79 |
+
mental_classifier.preprocess_data()
|
80 |
+
predicted_mental_category = mental_classifier.predict_category(user_message)
|
81 |
+
print("Predicted mental health condition:", predicted_mental_category)
|
82 |
|
83 |
+
# Detect sentiment
|
84 |
+
user_sentiment = chatbot.detect_sentiment(user_message)
|
85 |
|
86 |
+
# Retrieve question
|
87 |
+
if user_sentiment in ["Negative", "Moderately Negative"]:
|
88 |
+
question = retriever.get_response(user_message, predicted_mental_category)
|
89 |
+
show_question = True
|
90 |
+
else:
|
91 |
+
show_question = False
|
92 |
+
question = ""
|
93 |
+
predicted_mental_category = ""
|
94 |
+
|
95 |
+
# Update mood history / moode_trend
|
96 |
+
chatbot.update_mood_history()
|
97 |
+
mood_trend = chatbot.check_mood_trend()
|
98 |
+
|
99 |
+
# Define rewards
|
100 |
+
if user_sentiment in ["Positive", "Moderately Positive"]:
|
101 |
+
if mood_trend == "increased":
|
102 |
+
reward = +1
|
103 |
+
mood_trend_symbol = " ⬆️"
|
104 |
+
elif mood_trend == "unchanged":
|
105 |
+
reward = +0.8
|
106 |
+
mood_trend_symbol = ""
|
107 |
+
else: # decresed
|
108 |
+
reward = -0.2
|
109 |
+
mood_trend_symbol = " ⬇️"
|
110 |
|
111 |
+
else:
|
112 |
+
if mood_trend == "increased":
|
113 |
+
reward = +1
|
114 |
+
mood_trend_symbol = " ⬆️"
|
115 |
+
elif mood_trend == "unchanged":
|
116 |
+
reward = -0.2
|
117 |
+
mood_trend_symbol = ""
|
118 |
+
else: # decreased
|
119 |
+
reward = -1
|
120 |
+
mood_trend_symbol = " ⬇️"
|
121 |
+
|
122 |
+
print(
|
123 |
+
f"mood_trend - sentiment - reward: {mood_trend} - {user_sentiment} - 🛑{reward}🛑 -- (a)"
|
124 |
+
)
|
125 |
|
126 |
+
# Update Q-values
|
127 |
+
chatbot.update_q_values(
|
128 |
+
user_sentiment, chatbot.actions[0], reward, user_sentiment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
)
|
130 |
|
131 |
+
# Get recommended action based on the updated Q-values
|
132 |
+
ai_tone = chatbot.get_action(user_sentiment)
|
133 |
+
print(ai_tone)
|
134 |
+
# --------------
|
135 |
+
# LLM Response Generator
|
136 |
+
HUGGINGFACEHUB_API_TOKEN = os.getenv('HUGGINGFACEHUB_API_TOKEN')
|
137 |
+
|
138 |
+
llm_model = LLLResponseGenerator()
|
139 |
+
temperature = 0.1
|
140 |
+
max_length = 128
|
141 |
+
|
142 |
+
template = """INSTRUCTIONS: {context}
|
143 |
+
|
144 |
+
Respond to the user with a tone of {ai_tone}.
|
145 |
+
|
146 |
+
Question asked to the user: {question}
|
147 |
+
|
148 |
+
Response by the user: {user_text}
|
149 |
+
Response;
|
150 |
+
"""
|
151 |
+
context = "You are a mental health supporting non-medical assistant. Provide some advice and ask a relevant question back to the user."
|
152 |
+
|
153 |
+
llm_response = llm_model.llm_inference(
|
154 |
+
model_type="huggingface",
|
155 |
+
question=question,
|
156 |
+
prompt_template=template,
|
157 |
+
context=context,
|
158 |
+
ai_tone=ai_tone,
|
159 |
+
questionnaire=predicted_mental_category,
|
160 |
+
user_text=user_message,
|
161 |
+
temperature=temperature,
|
162 |
+
max_length=max_length,
|
163 |
+
)
|
164 |
+
st.session_state.messages.append({"role": "ai", "content": llm_response})
|
165 |
|
166 |
+
with st.chat_message("ai"):
|
167 |
+
st.markdown(llm_response)
|
168 |
+
# st.write(f"{llm_response}")
|
169 |
+
if show_question:
|
170 |
+
st.write(f"{question}")
|
171 |
+
# else:
|
172 |
+
# user doesn't feel negative.
|
173 |
+
# get question to ecourage even more positive behaviour
|
174 |
|
175 |
st.subheader("Behind the Scence - What AI is doing:")
|
176 |
+
st.write(
|
177 |
+
f"- Detected User Tone: {user_sentiment} ({mood_trend.capitalize()}{mood_trend_symbol})"
|
178 |
+
)
|
179 |
+
if show_question:
|
180 |
+
st.write(
|
181 |
+
f"- Possible Mental Condition: {predicted_mental_category.capitalize()}"
|
182 |
+
)
|
183 |
st.write(f"- AI Tone: {ai_tone.capitalize()}")
|
184 |
+
st.write(f"- Question retrieved from: {selected_retriever_option}")
|
185 |
+
st.write(
|
186 |
+
f"- If the user feels neagative or moderately negative, at the end of the AI response, it adds a mental health condition realted question. The question is retrieved from DB. The categories of questions are limited to Depression, Anxiety, and ADHD which are most associated with FOMO related to excessive social media usage."
|
187 |
+
)
|
188 |
+
st.write(
|
189 |
+
f"- Below q-table is continously updated after each interaction with the user. If the user's mood increases, AI gets reward. Else, AI gets punishment."
|
190 |
+
)
|
191 |
|
192 |
# Display results
|
193 |
# st.subheader(f"{user_sentiment.capitalize()}")
|
data/adhd_questions.txt
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
How often have you been feeling excessive worry or nervousness, even about everyday things?
|
2 |
+
How often do you experience physical symptoms like racing heart, sweating, or shortness of breath when feeling anxious?
|
3 |
+
How often do you encounter certain situations or triggers that cause you significant anxiety?
|
4 |
+
How often do you find yourself avoiding places or activities due to anxiety?
|
5 |
+
How often have you had trouble sleeping or concentrating because of anxious thoughts?
|
6 |
+
How often do you feel a constant need to be in control or have things perfect to avoid anxiety?
|
7 |
+
How often do you have intrusive thoughts that are difficult to stop?
|
8 |
+
How often do you experience sudden feelings of intense fear or panic (panic attacks)?
|
9 |
+
How often has your anxiety significantly impacted your daily life or relationships?
|
10 |
+
How much does anxiety interfere with your daily life?
|
11 |
+
How often have you felt nervous, anxious, or on edge?
|
12 |
+
How often have you found it difficult to stop or control worrying thoughts in the last two weeks?
|
13 |
+
Have you experienced restlessness or felt keyed up or on edge due to anxiety in the past two weeks?
|
14 |
+
How often have you felt easily fatigued or had difficulty concentrating because of anxiety recently?
|
15 |
+
Have you noticed irritability or muscle tension as a result of feeling anxious over the past two weeks?
|
16 |
+
How often have you had trouble falling asleep, staying asleep, or restless sleep due to anxiety in the last two weeks?
|
17 |
+
Do you find yourself easily startled or feeling on edge most days because of anxiety?
|
18 |
+
How often have you experienced physical symptoms like sweating, trembling, or a racing heart due to anxiety recently?
|
19 |
+
Have you found it challenging to relax or felt restless most days because of anxiety in the past two weeks?
|
20 |
+
How often have you felt a sense of impending doom or danger because of anxiety over the past two weeks?
|
21 |
+
How often do you feel nervous or on edge?
|
22 |
+
Do you have trouble relaxing or controlling your worries?
|
23 |
+
Have you experienced a racing or irregular heartbeat?
|
24 |
+
Do you feel like you're constantly on guard or on high alert?
|
25 |
+
Have you noticed any physical symptoms like trembling or sweating?
|
26 |
+
Do you feel like you're having trouble concentrating or making decisions?
|
27 |
+
Have you experienced any feelings of detachment or disconnection from others?
|
28 |
+
Do you feel like you're having trouble sleeping or experiencing vivid dreams?
|
29 |
+
Have you noticed any changes in your appetite or eating habits?
|
30 |
+
Have you considered seeking professional help for your anxiety?
|
data/anxiety_questions.txt
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
How often have you been feeling excessive worry or nervousness, even about everyday things?
|
2 |
+
How often do you experience physical symptoms like racing heart, sweating, or shortness of breath when feeling anxious?
|
3 |
+
How often do you encounter certain situations or triggers that cause you significant anxiety?
|
4 |
+
How often do you find yourself avoiding places or activities due to anxiety?
|
5 |
+
How often have you had trouble sleeping or concentrating because of anxious thoughts?
|
6 |
+
How often do you feel a constant need to be in control or have things perfect to avoid anxiety?
|
7 |
+
How often do you have intrusive thoughts that are difficult to stop?
|
8 |
+
How often do you experience sudden feelings of intense fear or panic (panic attacks)?
|
9 |
+
How often has your anxiety significantly impacted your daily life or relationships?
|
10 |
+
How much does anxiety interfere with your daily life?
|
11 |
+
How often have you felt nervous, anxious, or on edge?
|
12 |
+
How often have you found it difficult to stop or control worrying thoughts in the last two weeks?
|
13 |
+
Have you experienced restlessness or felt keyed up or on edge due to anxiety in the past two weeks?
|
14 |
+
How often have you felt easily fatigued or had difficulty concentrating because of anxiety recently?
|
15 |
+
Have you noticed irritability or muscle tension as a result of feeling anxious over the past two weeks?
|
16 |
+
How often have you had trouble falling asleep, staying asleep, or restless sleep due to anxiety in the last two weeks?
|
17 |
+
Do you find yourself easily startled or feeling on edge most days because of anxiety?
|
18 |
+
How often have you experienced physical symptoms like sweating, trembling, or a racing heart due to anxiety recently?
|
19 |
+
Have you found it challenging to relax or felt restless most days because of anxiety in the past two weeks?
|
20 |
+
How often have you felt a sense of impending doom or danger because of anxiety over the past two weeks?
|
21 |
+
How often do you feel nervous or on edge?
|
22 |
+
Do you have trouble relaxing or controlling your worries?
|
23 |
+
Have you experienced a racing or irregular heartbeat?
|
24 |
+
Do you feel like you're constantly on guard or on high alert?
|
25 |
+
Have you noticed any physical symptoms like trembling or sweating?
|
26 |
+
Do you feel like you're having trouble concentrating or making decisions?
|
27 |
+
Have you experienced any feelings of detachment or disconnection from others?
|
28 |
+
Do you feel like you're having trouble sleeping or experiencing vivid dreams?
|
29 |
+
Have you noticed any changes in your appetite or eating habits?
|
30 |
+
Have you considered seeking professional help for your anxiety?
|
data.csv → data/data.csv
RENAMED
File without changes
|
data/depression_questions.txt
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
How often have you felt persistently low in mood or sad for most of the day?
|
2 |
+
How often have you lost interest or pleasure in activities you used to enjoy?
|
3 |
+
How often have you experienced significant changes in appetite or weight (up or down)?
|
4 |
+
How often have you had trouble sleeping or sleeping too much?
|
5 |
+
How often have you felt restless or slowed down most of the time?
|
6 |
+
How often have you felt worthless or excessively guilty, even for minor things?
|
7 |
+
How often have you had difficulty thinking, concentrating, or making decisions?
|
8 |
+
How often have you had recurrent thoughts of death or suicide?
|
9 |
+
How often have you felt hopeless or like there's no point in life?
|
10 |
+
How often have you felt isolated or withdrawn from others due to your mood?
|
11 |
+
How often have you felt down, depressed, or hopeless?
|
12 |
+
How often have you had little interest or pleasure in doing things over the past two weeks?
|
13 |
+
Have you experienced changes in your appetite or weight due to feeling depressed in the last two weeks?
|
14 |
+
How often have you had trouble falling asleep, staying asleep, or sleeping too much because of feeling depressed?
|
15 |
+
Have you felt tired or had little energy most days over the past two weeks due to depression?
|
16 |
+
How often have you felt bad about yourself or that you are a failure or have let yourself or your family down in the last two weeks?
|
17 |
+
Have you had trouble concentrating on things like reading, watching TV, or engaging in conversations due to feeling depressed?
|
18 |
+
How often have you thought that you would be better off dead or hurting yourself in some way over the past two weeks?
|
19 |
+
Do you feel restless or slowed down physically most days because of feeling depressed in the last two weeks?
|
20 |
+
How often have you found it difficult to make decisions or felt indecisive due to feeling depressed recently?
|
21 |
+
How often do you feel sad or hopeless?
|
22 |
+
Do you have trouble getting out of bed or motivating yourself to do things?
|
23 |
+
Have you experienced a loss of interest in activities or hobbies?
|
24 |
+
Do you feel like you're not good enough or that you've failed at things?
|
25 |
+
Have you noticed any changes in your appetite or sleep patterns?
|
26 |
+
Do you feel like you're isolated from others or that you don't have any support?
|
27 |
+
Have you experienced any thoughts of self-harm or suicide?
|
28 |
+
Do you feel like you're stuck in a rut or that you can't see a way out of your current situation?
|
29 |
+
Have you noticed any physical symptoms like fatigue or loss of energy?
|
30 |
+
Have you considered seeking professional help for your depression?
|
llm_response_generator.py
CHANGED
@@ -93,7 +93,7 @@ class LLLResponseGenerator():
|
|
93 |
question=question,
|
94 |
user_text=user_text,
|
95 |
)
|
96 |
-
|
97 |
# Extracting only the response part from the output
|
98 |
response_start_index = response.find("Response;")
|
99 |
return response[response_start_index + len("Response;"):].strip()
|
|
|
93 |
question=question,
|
94 |
user_text=user_text,
|
95 |
)
|
96 |
+
print(response)
|
97 |
# Extracting only the response part from the output
|
98 |
response_start_index = response.find("Response;")
|
99 |
return response[response_start_index + len("Response;"):].strip()
|
q_learning_chatbot.py
CHANGED
@@ -11,7 +11,7 @@ import torch
|
|
11 |
|
12 |
|
13 |
class QLearningChatbot:
|
14 |
-
def __init__(self, states, actions, learning_rate=0.
|
15 |
self.states = states
|
16 |
self.actions = actions
|
17 |
self.learning_rate = learning_rate
|
|
|
11 |
|
12 |
|
13 |
class QLearningChatbot:
|
14 |
+
def __init__(self, states, actions, learning_rate=0.9, discount_factor=0.1):
|
15 |
self.states = states
|
16 |
self.actions = actions
|
17 |
self.learning_rate = learning_rate
|
xgb_mental_health.py
CHANGED
@@ -58,7 +58,7 @@ class MentalHealthClassifier:
|
|
58 |
|
59 |
if __name__ == "__main__":
|
60 |
tokenizer_model_name = "nlptown/bert-base-multilingual-uncased-sentiment"
|
61 |
-
data_path = 'data.csv'
|
62 |
model_path = 'mental_health_model.pkl'
|
63 |
mental_classifier = MentalHealthClassifier(data_path, model_path)
|
64 |
|
|
|
58 |
|
59 |
if __name__ == "__main__":
|
60 |
tokenizer_model_name = "nlptown/bert-base-multilingual-uncased-sentiment"
|
61 |
+
data_path = 'data/data.csv'
|
62 |
model_path = 'mental_health_model.pkl'
|
63 |
mental_classifier = MentalHealthClassifier(data_path, model_path)
|
64 |
|