Chat with your medical PDFs. Ask in plain English. Get answers grounded in your documents.
This project is an AI-powered medical document question-answering system built using Large Language Models (LLMs) and vector-based information retrieval. It enables users to ask natural language questions and receive accurate, context-aware answers derived from medical PDF documents.
The system works by loading and splitting PDF documents into smaller chunks, generating vector embeddings using a Hugging Face embedding model, and storing them in Pinecone, a scalable vector database. During inference, user queries are matched against relevant document chunks using similarity search, and responses are generated using LLaMA-2 through a retrieval-augmented generation (RAG) pipeline.
This project demonstrates practical implementation of LLMs + LangChain + Vector Databases for real-world AI applications.
- PDF-based medical document ingestion
- Vector similarity search using Pinecone
- Retrieval-Augmented Generation (RAG) pipeline
- Local LLaMA-2 model inference
- Interactive web interface using Flask
- Modular and extensible architecture
PDF → Embeddings → Pinecone → LLaMA-2 → Answer
| Phase | Command | What happens |
|---|---|---|
| 1. Index once | python store_index.py |
Loads PDFs, splits text into chunks, generates embeddings, stores vectors in Pinecone |
| 2. Ask anytime | python app.py |
Retrieves the most relevant chunks and generates an answer with LLaMA-2 |
- Python
- LangChain
- Flask
- Meta LLaMA-2
- Pinecone (Vector Database)
- Hugging Face Embeddings
Follow the steps below to set up and run the project locally.
git clone https://github.com/<your-username>/MedQueryDoc-AI-Intelligent-Medical-Document-Assistant.git
cd MedQueryDoc-AI-Intelligent-Medical-Document-AssistantIf Conda is installed:
conda create -p ./venv python=3.10 -y
conda activate ./venvOr using Python venv:
python -m venv venv
venv\Scripts\activate # Windows
source venv/bin/activate # macOS / Linuxpip install -r requirements.txtCreate a .env file in the root directory and add your Pinecone credentials:
PINECONE_API_KEY=your_pinecone_api_key_here
⚠️ Note: Pinecone no longer requires an environment variable (PINECONE_API_ENV) in the new SDK.
Create a data/ folder in the project root and add your PDF files:
data/
├── medical_doc_1.pdf
├── medical_doc_2.pdf
Download the quantized LLaMA-2 model and place it inside the model/ directory:
Model: llama-2-7b-chat.ggmlv3.q4_0.bin
Source: https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML
Before running the chatbot, index the documents:
python store_index.pyThis step:
- Loads PDFs
- Splits text into chunks
- Generates embeddings
- Stores vectors in Pinecone
python app.pyThen open your browser and visit:
http://localhost:8080
├── app.py # Flask application
├── store_index.py # PDF ingestion & vector indexing
├── src/
│ ├── helper.py # PDF loading, chunking, embeddings
│ ├── prompt.py # Prompt template
├── model/
│ └── llama-2-7b-chat.ggmlv3.q4_0.bin
├── templates/
│ └── chat.html
├── static/
│ └── style.css
├── assets/
│ └── social-preview.png # Demo banner used in this README
├── data/ # PDF documents
└── .env
- Multilingual medical support
- Source citation in answers
- Document upload via UI
- Streaming responses
- Cloud-hosted inference
- Authentication & access control
This project is for informational and educational purposes only. It is not a medical device and is not a substitute for professional medical advice, diagnosis, or treatment. Always consult a qualified healthcare professional.
This project is licensed under the GNU General Public License v3.0.
See the LICENSE file for more details.
This project builds upon open-source tools and research in the fields of LLMs, NLP, and vector databases. Special thanks to the open-source community for enabling practical AI innovation.
If you found this project useful, please ⭐ star the repo!
