Clinicians, researchers, and data scientists often need up-to-date insights from PubMed but end up manually reading dozens of abstracts or forming complex search queries. This slows down literature review and clinical decision-making.
Provide a chat-style assistant that:
- Pulls the most relevant PubMed abstracts for a given topic in real-time.
- Leverages Retrieval-Augmented Generation (RAG) so GPT-4o mini can answer follow-up questions grounded in those abstracts.
- Available in both terminal and modern web interface.
User ⇄ Chat Interface (Terminal or Web) -> PubMed fetch (Entrez) -> Text chunking + BioBERT embedding -> ChromaDB vector storage -> GPT-4o answer
git clone https://github.com/Rithvik-katakamm/PubMedRAG.git
cd PubMedRAG
# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtCreate environment variables or a .env file:
OPENAI_API_KEY=sk-...
ENTREZ_EMAIL=your_email@example.comBeautiful Gemini-inspired dark theme with modern UI:
./run_web.sh
# Then open: http://localhost:8000Features:
- Dark theme with blue accents (like Gemini)
- Real-time text streaming
- Collapsible session sidebar
- Floating action buttons for chunks/metrics
- Elegant popups for viewing retrieved chunks
- Session management and history
Rich console-based interface:
./run.sh
# or
python src/app.pyFeatures:
- Beautiful terminal UI with Rich library
- Session persistence
- All slash commands (
/chunks,/clear,/help) - Progress indicators
The web interface features:
- Centered chat like Gemini
- Collapsible sidebar for session management
- Topic indicator in header
- Floating action buttons for:
- 📄 View retrieved chunks
- 📊 Data loading metrics
- 🗑️ Clear data
- ➕ New session
- Elegant modals for chunks and metrics
- Real-time streaming responses
- Python 3.8+
- OpenAI GPT-4o mini
- ChromaDB (vector database)
- BioBERT (medical embeddings)
- NCBI Entrez (PubMed API)
- FastAPI (backend)
- WebSockets (real-time communication)
- Modern HTML/CSS/JavaScript
- Dark theme with responsive design
- Rich (beautiful console output)
- Click (command-line interface)
rag_pubmed/
├── src/
│ ├── web_app.py # FastAPI web application
│ ├── app.py # Terminal application
│ ├── static/ # Web UI assets
│ │ ├── style.css # Gemini-inspired styling
│ │ └── script.js # Frontend JavaScript
│ ├── core/ # RAG engine
│ │ ├── rag_engine.py # Main orchestrator
│ │ ├── vector_db.py # ChromaDB manager
│ │ ├── retrieval.py # PubMed fetching
│ │ ├── chunking.py # Text processing
│ │ └── embeddings.py # BioBERT embeddings
│ ├── chat/ # Session management
│ └── ui/ # Terminal UI
├── run_web.sh # Web app launcher
├── run.sh # Terminal app launcher
└── requirements.txt # Dependencies
OPENAI_API_KEY- Your OpenAI API keyENTREZ_EMAIL- Email for NCBI Entrez API
The system is optimized for M2 Macs with:
- Max 5000 vectors per topic (sub-100ms retrieval)
- HNSW indexing for fast similarity search
- Automatic FIFO cleanup
- Web: Click ➕ button → Enter email and topic
- Terminal: Run app → Enter email and topic
- "What are the latest treatments for diabetes?"
- "How effective is immunotherapy for lung cancer?"
- "What are the side effects of metformin?"
- Web: Click 📄 button for elegant popup
- Terminal: Type
/chunksorc
- Web: Use collapsible sidebar
- Terminal: Use
/sessionscommand
- Sessions are persistent across restarts
- Vector data is stored in
./data/chroma_db/ - Each topic maintains its own collection
- FIFO cleanup prevents memory issues
- Works offline once data is loaded
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT License - see LICENSE file for details.
Switch to Ollama: You can replace OpenAI with Ollama for fully local operation!