{"id":22654165,"url":"https://github.com/gupta-aryaman/medimate","last_synced_at":"2025-04-12T04:13:11.563Z","repository":{"id":198910157,"uuid":"701630642","full_name":"Gupta-Aryaman/MediMate","owner":"Gupta-Aryaman","description":"XAI Medical Chatbot for Prescribing Medications and Treatment Plans","archived":false,"fork":false,"pushed_at":"2024-11-02T21:14:37.000Z","size":7381,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T04:13:03.857Z","etag":null,"topics":["aws","chatbot","explainable-ai","flask","llms","medical-chatbot","nextjs","text-embeddings"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Gupta-Aryaman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-07T05:31:28.000Z","updated_at":"2024-11-02T22:18:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"389c1ff1-de84-4eac-802d-753f1150e1a6","html_url":"https://github.com/Gupta-Aryaman/MediMate","commit_stats":null,"previous_names":["gupta-aryaman/minor","gupta-aryaman/medimate"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gupta-Aryaman%2FMediMate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gupta-Aryaman%2FMediMate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gupta-Aryaman%2FMediMate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gupta-Aryaman%2FMediMate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gupta-Aryaman","download_url":"https://codeload.github.com/Gupta-Aryaman/MediMate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248514203,"owners_count":21116903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","chatbot","explainable-ai","flask","llms","medical-chatbot","nextjs","text-embeddings"],"created_at":"2024-12-09T09:33:44.404Z","updated_at":"2025-04-12T04:13:11.535Z","avatar_url":"https://github.com/Gupta-Aryaman.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MediMate: AI-powered Medical Chatbot for Prescribing Medications and Treatment Plans\n\nMediMate is a cutting-edge AI-powered medical chatbot designed to offer personalized medical diagnoses and treatment plans. Built on Node.js, it leverages advanced machine learning models, including Large Language Models (LLMs) and vector embeddings, to provide accurate and tailored healthcare advice based on individual medical history. The system ensures that users have timely access to relevant medical guidance and can reference past conversations for continuity of care.\n\n## Our Aim\n\nMediMate is designed to:\n- Deliver personalized diagnoses based on the user's medical history.\n- Generate tailored treatment plans using Explainable AI, ensuring transparency and trust.\n- Store and reference previous conversations for follow-up and ongoing healthcare management.\n\nBy leveraging the power of AI, MediMate offers precise healthcare guidance that evolves with each user interaction, promoting better health outcomes through personalization and accessibility.\n\n## System Architecture\n\nMediMate’s architecture, based on RAG (Retrieval-Augmented Generation), consists of the following key components:\n\n1. **Frontend**: Developed using Next.js, the user interface allows patients to interact with the chatbot and view previous conversations. The frontend is integrated with ClerkAPI for user authentication.\n2. **Backend**: The Node.js backend handles requests from the frontend and interacts with the AI models to generate responses. It also routes API requests via an API Gateway and ensures the persistence of chat history.\n3. **AI Models**:\n   - **LLM (Large Language Model)**: A Llama-2-70B-Chat-GGML model is used for conversation generation. This model is optimized for CPU-based execution and handles context-aware responses, taking into account past interactions.\n   - **Vector Embeddings**: Medical knowledge from \"Harrison’s Principles of Internal Medicine\" is stored as vector embeddings, which are used to search for relevant information using a vector database (FAISS).\n4. **Database**: The FAISS vector database is used to store and retrieve vector embeddings, which are critical for matching user prompts with relevant medical knowledge. This ensures fast and accurate responses based on the user's query.\n\n#### Architecture of LLM - \u003cbr\u003e\n![image](https://github.com/user-attachments/assets/98e569c8-419b-48e6-ae83-7a08259798fa) \u003cbr\u003e \u003cbr\u003e\n#### Architecture of the application - \u003cbr\u003e\n![image](https://github.com/user-attachments/assets/31231f9a-ec7a-4c2a-abc2-db5952a3ec1e)\n\n## Features\n\n- **Personalized Diagnoses**: Uses vector embeddings to match symptoms with relevant medical data and provides a diagnosis.\n- **Treatment Plans**: Offers tailored treatment recommendations based on diagnosis and user medical history.\n- **Explainable AI**: Utilizes explainability in its AI models to ensure users understand the reasoning behind the diagnosis and treatment plans.\n- **Conversation History**: All chats are saved, allowing users to refer back to previous interactions for consistent and evolving healthcare advice.\n- **User Authentication**: Secure login and user management with ClerkAPI.\n\n## Setup Guide\n\nFollow these steps to set up MediMate on your local machine:\n\n### Prerequisites\n\n- **Node.js**: Ensure Node.js is installed (v14.x or higher).\n- **AWS Account**: For deploying the LLM model on AWS.\n- **ClerkAPI Account**: For user authentication setup.\n- **Docker**: (Optional) For containerized deployment.\n\n### Installation Steps\n\n1. **Clone the Repository**\n   ```bash\n   git clone https://github.com/Gupta-Aryaman/MediMate.git\n   cd MediMate\n   ```\n#### Running node frontend - \n2. **Install Dependencies**\n   ```bash\n   cd app\n   npm install\n   ```\n\n3. **Set up Environment Variables**\n   - Create a `.env` file in the root directory and configure the following variables:\n     ```\n     CLERK_API_KEY=\u003cYour Clerk API Key\u003e\n     AWS_ACCESS_KEY=\u003cYour AWS Access Key\u003e\n     AWS_SECRET_KEY=\u003cYour AWS Secret Key\u003e\n     ```\n\n4. **Run the Application**\n   ```bash\n   npm run dev\n   ```\n\n5. **Deploying the LLM Model**\n   - The LLM model is deployed on AWS using an API Gateway. Follow AWS deployment instructions for model deployment.\n\n6. **Accessing the App**\n   - Open your browser and navigate to `http://localhost:3000` to access the MediMate app.\n  \n#### Running python backend -\n2. **Create a virtual environment**\n  ```bash\n  cd model\n  python3 -m venv venv\n  source venv/bin/activate   # On Windows use `venv\\Scripts\\activate`\n  ```\n\n3. **Install the required dependencies**\n  ```bash\n  pip install -r requirements.txt\n  ```\n\n4. **Run the project**\n  ```bash\n  python main.py\n  ```\n\u003e ### We ran the Llama-2 LLM on AWS sagemaker. To access the model on local machine we used a Bastion server. You can find more details on how to implement this approach [here](https://ruslanmv.com/blog/How-to-connect-to-Sagemaker-Notebook-via-SSH)\n\n## Testing\nAt the end, 2 machines were created and the results were compared for a set of questions (19) (read about it in more detail [here](https://github.com/Gupta-Aryaman/MediMate/tree/main/reports)) -  \n- BLUE - (Ref- https://huggingface.co/hkunlp/instructor-large )\n```\nGPU Memory - 16gb\nGPU 0- Tesla T4\n23 Prompts\nEmbeddings used - hkunlp/instructor-large (variating here)\nModel used - Llama 2 13B, 128 group size model - GPTQ\nDatabase used - Faiss (constant)\n```\n- ORANGE-  (Ref- https://huggingface.co/hkunlp/instructor-xl )\n```\nCPU Memory - 192gb\nCPU- Intel Xeon Platinum 8275CL (Cascade Lake)\n23 Prompts\nEmbeddings used - hkunlp/instructor-xl (variating here)\nModel used - Llama 2 13B, 128 group size model-GGUF\nDatabase used - Faiss (constant)\n```\n![image](https://github.com/user-attachments/assets/e826e5bf-0ba3-462c-a2de-0f2659ec582c)\n\n## License\n\nThis project is licensed under the [MIT License](https://github.com/Gupta-Aryaman/MediMate/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgupta-aryaman%2Fmedimate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgupta-aryaman%2Fmedimate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgupta-aryaman%2Fmedimate/lists"}