Getting Started
Follow this tutorial to understand how the Medical AI Chatbot processes medical documents, retrieves relevant information, and generates responses using a Retrieval-Augmented Generation (RAG) pipeline.
Prepare the Medical Documents
Place the medical PDF documents that will form the chatbot's knowledge base in the project's document directory.
Extract and Split Text
The application reads the PDF files and extracts their text. Large documents are then divided into smaller chunks so that relevant sections can be retrieved efficiently.
PDF
↓
Text extraction
↓
Text splitting
↓
Document chunks
Create Embeddings
Each document chunk is converted into an embedding — a numerical representation that captures the semantic meaning of the text.
These vector representations allow the system to identify information that is semantically similar to a user's question.
Store the Vectors
The generated embeddings are stored in Pinecone together with the associated document information.
Document chunk
↓
Embedding model
↓
Vector
↓
Pinecone index
Ask a Question
The user enters a medical-related question through the chatbot interface.
For example:
What are the common symptoms of iron deficiency?
Retrieve Relevant Information
The user's question is converted into an embedding and compared with the vectors stored in Pinecone.
The most relevant document chunks are retrieved and supplied as context for the language model.
Generate the Answer
LangChain coordinates the retrieval and generation process. The retrieved context is provided to GPT-4o, which generates the final natural-language response.
User question
↓
Retriever
↓
Relevant documents
↓
Prompt + context
↓
GPT-4o
↓
Answer
Run the Application
The Flask application provides the web interface and backend API used by the chatbot.
python app.py
Once the Flask server is running, open the application in a browser and submit a question through the chat interface.
Deployment
For deployment, the application can be packaged using Docker and deployed to an AWS environment. GitHub Actions can automate the build and deployment workflow.
git push
↓
GitHub Actions
↓
Build Docker image
↓
Deploy
↓
Running application