Lifestyle Bot (improves health/wellness)
Mental health is a complex issue and addressing mental health demands the highest level of attention and care. Unlike many other health concerns, mental health issues often intertwine with various aspects of an individual's life, including their social environment, personal experiences, and genetic predispositions. Additionally, the stigma surrounding mental health further complicates the matter, hindering individuals from seeking help and society from providing adequate support systems.
The main goal of this project is to provide a support system for an individuals's mental well-being.
Generative AI has ushered in a new era for chatbots, providing them with capabilities to engage users in more natural conversations. Generative AI models also known as LLMs(Large Language Models) have given us the opportunity to offer more personalized and foster more engaging interactions. But deploying these LLMs in consumer applications poses several challenges, including the need to add guardrails that prevent the model from generating undesirable responses. For example, in the context of building an AI for mental health, then you don't want it to generate toxic answers that bring more mental distress or teach people to engage in behaviors harmful to oneself.
To align these LLMs according to a set of values, researchers at Anthropic have proposed a technique called Constitutional AI (CAI), which asks the models to critique their outputs and self-improve according to a set of user-defined principles.
Afer aliging the model, it is important to have the right prompt to guide the model to generate meaningful responses that promote mental well-being, the idea is to explore Role based prompt engineering
technique, so that the model can generate responses that are consistent with principles from Adlerian Psychology Inspiration . Please refer to the table below for some of the principles and their advantages.
Principle | Advantage |
---|---|
Encouragement and Empowerment | Fosters self-efficacy and resilience, providing supportive guidance to build user confidence in coping with challenges. |
Goal Orientation | Promotes setting meaningful goals and developing actionable strategies, fostering a sense of purpose and direction. |
Social Interest | Emphasizes the significance of social connection and community involvement, enhancing a sense of belonging. |
Utilizing role-based prompt engineering alongside these principles ensures that the model generates responses that are consistent with Adlerian Psychology, thereby enhancing the effectiveness and relevance of the chatbot's interactions.
Mental Wellness Companion
This bot fosters emotional well-being by generating personalized affirmations, guided meditations, and mindfulness exercises based on the user's mood and current needs.
Create Synthetic Data with LLMs using llm-swarm
. Build two datasets, an SFT dataset and a preference dataset.
CHAT MODEL - The idea is to use Constituional AI to bake in harmlessness into the Llama-2-7b-chat-hf
model and following that, employ prompt engineering techniques to integrate Adlerian psychology principles
into the model.
MODERATION MODEL - LlamaGuard-7b
a safeguard model to ensure user inputs and model responses are safe.
python -V
# Output -> Python 3.10.13
# create a environment named -> .wellness-ai-agent
python -m venv .wellness-ai-agent
# activate the environment
source .wellness-ai-agent/bin/activate
# Install packages to create a Jupyter Notebook kernel
pip install jupyter ipykernel
# add your virtual environment as a kernel
python -m ipykernel install --user --name=wellness-ai-agent --display-name="Py3.10-wellness-ai-agent"
# verify kernel installation
jupyter kernelspec list
# Install the gcloud CLI - https://cloud.google.com/sdk/docs/install#linux
# Determine Linux version
getconf LONG_BIT
# Output -> 64, therefore chose Linux 64-bit(Arm)
# Download the Linux archive file
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-478.0.0-linux-arm.tar.gz
# Extract the contents of the file
tar -xf google-cloud-cli-478.0.0-linux-arm.tar.gz
# Add gcloud CLI to path
./google-cloud-sdk/install.sh
# Then open a new terminal so that changes can take effect
# Initialize gcloud CLI
./google-cloud-sdk/bin/gcloud init
# remove the tar file
rm -rf google-cloud-cli-478.0.0-linux-arm.tar.gz
# Get sample cloud functions - https://cloud.google.com/functions/docs/tutorials/http
git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
# Set a default region for functions -> https://cloud.google.com/functions/docs/locations
gcloud config set functions/region europe-west3
# Output -> Updated property [functions/region].
```
```bash
# Deploying the Cloud Function -> https://cloud.google.com/functions/docs/tutorials/http
gcloud functions deploy python-http-function \
--gen2 \
--runtime=python310 \
--source=. \
--entry-point=hello_get \
--trigger-http
--allow-unauthenticated
# Notes:
# - source: path to the directory where the .py file exists with the function you want to deploy
# Retrieve your functions's URL -> https://cloud.google.com/functions/docs/calling/http#url
gcloud functions describe python-http-function \
--gen2 \
--region=europe-west3 \
--format="value(serviceConfig.uri)"
# Output -> https://europe-west3-gcp-lablab-ai-hackathon.cloudfunctions.net/python-http-function
# Delete the Cloud Function
gcloud functions delete python-http-function --gen2 --region europe-west3
```
## References
- [Project Motivation](https://github.com/pandeyanuradha/Chatbot-for-mental-health?tab=readme-ov-file#motivation-behind-this-project)
- [HuggingFace Blog Post on Constitutional AI](https://huggingface.co/blog/constitutional_ai)
- [Adlerian Psychology Book Summary](https://www.kadlac.com/notes/the-courage-to-be-disliked)
## License
The content of this repository is licensed under a [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0)