Project
10
↳
Text Mining with Large Language Models (LLM)
OpenAI | Sentiment Analysis
Project information
This is a sentiment analysis application that I built using Langchain and the OpenAI API, with daily operations facilitated via Twilio.
Users submit daily journal entries, which are processed to analyze sentiment and other mental health indicators. The information is logged into a HIPPA Compliant Back4app NoSQL database, accessible to medical professionals through a dashboard. They can view journal entries and export data in CSV or JSON format for further analysis.
Additionally, quizzes can be automated and sent out to individuals to further assess their mental state. Some of the mental health quizzes sent out include:
PHQ-9 (Patient Health Questionnaire-9): Assesses the severity of depression.
GAD-7 (Generalized Anxiety Disorder-7): Screens for and measures the severity of generalized anxiety disorder.
PSS (Perceived Stress Scale): Evaluates the perception of stress.
Mood Disorder Questionnaire (MDQ): Screens for mood disorders.
Beck Depression Inventory (BDI): Measures the severity of depression.
Patient Advocate Assignment:
Advocates are also assigned to patients to track any unlogged events, helping medical professionals or overseeing parties review recent occurrences. This ensures that no significant events are missed, providing a comprehensive view of home activities.
Simplified Sentiment Analysis Process:
Daily SMS Prompt: Using Twilio, users receive a daily SMS asking about their well-being.
Journal Entry Submission: Users reply with their journal entries.
Data Parsing: The entries are parsed using Langchain to extract key information such as sentiment, mental state, subject, keywords, and more.
Sentiment Analysis: The parsed data is analyzed using an emotionally-agnostic sentiment analysis model.
Database Logging: The structured data is logged into a Back4app NoSQL database.
Dashboard Access: Medical professionals can access the logged entries via a dashboard, view trends, and export data for further analysis.
Daily SMS:
Mental Health Quiz:
Simplified Dashboard View: View sentiment summaries, and export data for further analysis.
Simplified Model Output: After a user's input is processed through OpenAIs LLM.
Simplified Model Output Descriptions:
Username: Identifies the user submitting the entry.
Mental State: Declares the mental state suggested by the user's prompt.
Sentiment: The overall sentiment of the input (Positive, Negative, Neutral).
Subject: Specifies the subject or topic of the input, including any negativity.
Keywords: Identifies key words in the user's input.
Input Summary: Summarizes the user's input after checking for grammar and punctuation errors and provides an interpretation of the intent.
Action: Labels the action the person is attempting, describing the reaction and outcome.
Alert: Indicates if the input could lead to harm and what the outcome might be.
Course of Action: Suggests intervention steps if necessary.
This system enhances user interaction and provides valuable insights into user sentiment and mental health trends, enabling medical professionals to offer better support and intervention.
Simplified Knowledge Graph View:
The logs in the database will be accessible to medical professionals via a dashboard where they can overview all journal entries from patients and assigned advocates. They can also export the data in CSV or JSON format to be imported into a Knowledge Graph for further analysis.
A Knowledge Graph enables a more intricate and interconnected view of the data by visualizing relationships and patterns that might not be immediately obvious. By mapping out how different ideas and sentiments are connected, medical professionals can gain deeper insights into a patient’s mental state and progress over time. This can reveal trends such as the recurrence of certain themes or emotions, the impact of specific events on a patient's mental health, and the overall trajectory of their well-being. Such detailed analysis can inform better therapeutic strategies and personalized care plans, enhancing the support provided to patients.
This system enhances user interaction and provides valuable insights into user sentiment and mental health cycles, enabling medical professionals to offer better support and intervention.
Backlog:
In the coming months, I plan to enhance the system to make the user experience feel more like a conversation stream between the AI and the patient. This will allow conversations to be recorded and streamed in real-time, with the data being registered into a Knowledge Graph. This will enable real-time visualization of how ideas are formed, what they are connected to, and how certain ideas may develop into detrimental clusters of viewpoints about the world.