Medical AI Chatbot

Documentation

Technical documentation for the Medical AI Chatbot, a Retrieval-Augmented Generation (RAG) application designed to retrieve information from medical documents and generate context-aware responses.

Overview

The Medical AI Chatbot combines document retrieval, vector embeddings, and large language model generation to answer medical-related questions using information contained within a curated knowledge base.

Medical PDFs
Text Chunks
Vector Embeddings
Retriever
User Query
Relevant Context
GPT-4o
Generated Answer

Technology Stack

RAG Pipeline

1. Document ingestion

Medical PDF documents are loaded and processed into machine-readable text.

2. Text splitting

Large documents are divided into smaller chunks so that relevant sections can be retrieved efficiently.

3. Embedding generation

Each text chunk is converted into a numerical vector representation using an embedding model.

4. Vector storage

The embeddings and their associated text are stored in Pinecone.

5. Query retrieval

When a user submits a question, the question is converted into an embedding and compared with the stored vectors to identify relevant document chunks.

6. Response generation

The retrieved context is supplied to GPT-4o through the application pipeline, allowing the model to generate an answer grounded in the retrieved information.

Example Request Flow

User Question
     ↓
Question Embedding
     ↓
Pinecone Similarity Search
     ↓
Relevant Medical Text
     ↓
LangChain Retrieval Pipeline
     ↓
GPT-4o
     ↓
Final Response
    

Configuration

API credentials and configuration values should be stored as environment variables rather than hard-coded in application files.

OPENAI_API_KEY=your_api_key
PINECONE_API_KEY=your_api_key
PINECONE_INDEX_NAME=your_index
    
Do not commit API keys or other credentials to GitHub or include them directly in frontend source code.

Deployment

The application can be packaged as a Docker container and deployed to an AWS environment. GitHub Actions can be used to automate testing, image building, and deployment.

← Back to Home