Case Studies, Tech Trends

AI Chatbot for People Suffering From PTSD

Akvelon's innovative AI chatbot for mental health empowers individuals who are coping with PTSD. By integrating Langchain and implementing custom memory summarization, we've equipped our chatbot to hold longer conversations that are contextually precise and deliver tailored support.

PTSD Chatbot Akvelon's Impact

Project Background & Goals

At Akvelon, we constantly experiment with the latest AI innovations to assess their practical applications and address real-world challenges. When ChatGPT-4 launched in March 2023, our AI and ML teams eagerly delved into exploring its great potential in the healthcare sector.

The concept of developing an AI chatbot for mental health resonated especially strongly with us, mainly due to Akvelon’s extensive presence in Ukraine, where many of our team members have been personally affected by the Russo-Ukrainian war. Research into mental health in Ukraine revealed concerning findings from a 2023 study, which documented the prevalence of PTSD following the first year of the full-scale invasion of Ukraine:

  • Over 50% of respondents met PTSD diagnosis criteria across all groups.

  • Up to 62% of refugees showed signs of PTSD.

Additionally, access to mental health treatment in Ukraine, especially for people suffering from PTSD, was severely limited due to a shortage of qualified professionals and the many disruptions caused by wartime conditions.

Further investigation revealed alarming global statistics – approximately 3.9% of the world’s population experience PTSD, according to the World Mental Health Surveys. Moved by these insights, we aimed to create a free, accessible, and anonymous solution that leverages AI to offer support for people suffering from PTSD. We aimed to especially help those who lacked access to professional treatment, or were hesitant to share their mental health challenges with others.

Technologies and Solutions Used: ChatGPT-4, Langchain, Python, React, and Redis

Technical Challenges & Solutions

Our AI & ML engineers worked on two distinct chatbot versions: a web-based version and a Telegram version. One of the key challenges they faced when experimenting with ChatGPT-4 was maintaining context and continuity in lengthy chatbot conversations.

GPT-4's maximum token limit for input sequences is typically around 4,096 tokens. When conversations go beyond this limit, GPT-4 cuts them off, only processing a part of the conversation history. This made it difficult for GPT-4 to understand the full context of longer interactions, hindering the chatbot's ability to have meaningful conversations over time.

To address the token limitation of the GPT-4 model, our engineers employed a different approach to summarization for each version of the chatbot.

1. For the Telegram version, we leveraged Langchain's memory summarization feature - but with a twist. Instead of using Langchain’s default method of storing all messages in a form of single history, we created a custom function that summarized each message individually and stored these summaries separately. This approach ensured that GPT-4 responded solely to the most recent message while retaining the context of the preceding history, resulting in concise responses and minimized repetition.

2. The web-based version integrated directly with ChatGPT's API. If the conversation exceeded the GPT-4’s limit, the system prompted ChatGPT to summarize past messages, creating a condensed version of each message and storing those summaries in a Redis database.

While tackling these technical challenges, we also prioritized user experience. We employed best practices and prompt engineering to craft accurate and helpful responses.

Akvelon PTSD Chatbot Screenshots

Impact and Potential Applications

We were fast to pioneer GPT-4 for Healthcare immediately after its release, and developed two AI chatbot versions, navigating the model’s limitations for our custom use case.

Teams’ Achievements:

  • Exceeding ChatGPT-4 Boundaries: we successfully implemented innovative solutions, such as Langchain integration with custom memory summarization, to enhance conversation coherence, overcoming ChatGPT-4's technical limitations.

  • Powering Social Impact: our PTSD chatbots provide free and anonymous support for those struggling with mental health challenges. They offer comfort and understanding through personalized responses and compassionate interactions, helping users feel validated and empowered as they navigate through their life journeys.

  • Providing Flexibility for Clinical Use: our chatbots can integrate into clinical workflows, supporting medical professionals in diagnosing and treating PTSD. By training them on trusted medical sources, these chatbots can deliver responses based solely on verified studies, ultimately elevating the quality of care. Moreover, we can extend their applicability beyond mental health to other domains.

PTSD Chatbots’ Benefits:

  • 24/7 support for patients who need immediate & accessible help

  • Personalized responses based on individual needs & progress

  • Compliance with security & privacy regulations 

  • Anonymity & data protection ensured for all users

Potential Business Impact:

Akvelon's PTSD Chatbot Benefits

What’s Next: Validating Our PTSD Chatbots

Now, we're in a comprehensive validation process of our chatbots, gathering feedback through beta testing and clinical studies. This feedback from both medical professionals and users will not only validate their effectiveness, but also guide future improvements. We're also collaborating with psychology experts to enhance our chatbots’ ability to respond with empathy, ensuring they connect with users on an emotional level. Our focus is on creating AI solutions that deliver measurable benefits and make a real difference in people's lives.