Skip to content

A sophisticated medical information retrieval and question-answering system that combines Retrieval-Augmented Generation (RAG) with Google's Gemini AI model, and source citations.

License

Notifications You must be signed in to change notification settings

gaurabacharya/Medical-RAG-Chatbot

Repository files navigation

Medical-RAG-Chatbot

Demo of the API working with a frontend UI

https://youtu.be/-NcgFqA0GN8

Summary

This medical chatbot was created using RAG (Retrieval Augmented Generation) to produce more correct responses than the LLM model by providing context data from a vectorized database that can be updated with more recent data. This extra context reduces hallucinations in responses, the system prompt creates consistent responses, and citations to where the top 3 sources that provided the context are also provided in the response. Although there is html code for a simple UI, the main purpose is to create an backend API endpoint using Flask to be used in another frontend program with a better UI which is in another repository here. The data that was provided was the Gale Encyclopedia of Medicine and the data was split and embedded using the all-MiniLM-L6-v2 from hugging face. The vectorized data was then stored on PineCone. Used langchain to create documents, split, create the retrieval chain to retrieve the context from Pinecone, and apply the prompt to our LLM. Lastly, the LLM that was used was gemini-2.0-flash.

Medical Chatbot

How to Run

Step 1: Copy the repo and create a virtual environment

python3.10 -m venv llmapp

Activate it

Mac

source ./llmapp/bin/activate

Windows

 env/Scripts/activate.bat // in CMD

Step 2: Install the requirements

pip install -r requirements.txt

Step 3: Obtain API Keys and store them in .env file

PINECONE_API_KEY = "..."
GOOGLE_API_KEY = "..."

PineCone Google API Key

Step 4: Run store_index.py to upload data to PineCone

cd <working directory>
python store_index.py

Step 5: Run app.py locally

python app.py

Now you can ask medical question to the bot!

About

A sophisticated medical information retrieval and question-answering system that combines Retrieval-Augmented Generation (RAG) with Google's Gemini AI model, and source citations.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published