Medic / README.md
mgbam's picture
Add application file
b8986a1
---
title: Med
emoji: πŸ†
colorFrom: blue
colorTo: purple
sdk: streamlit
sdk_version: 1.43.2
app_file: app.py
pinned: false
short_description: Medical field with next‑gen technology
---
# AI-Powered Medical Knowledge Graph Assistant (Mini-LADDER Demo)
This repository demonstrates a Streamlit application that:
- Retrieves PubMed abstracts via NCBI’s E-utilities.
- Indexes and retrieves relevant documents using ChromaDB.
- Generates biomedical answers using Microsoft BioGPT-Large-PubMedQA.
- Applies a two-stage self-improvement mechanism (inspired by Tufa Labs’ LADDER) that:
- Generates naive sub-questions.
- Produces an initial answer.
- Self-critiques and refines the answer.
- Visualizes key terms in a knowledge graph using PyVis.
## Key Features
1. **PubMed + Chroma**: Retrieves and indexes relevant abstracts.
2. **BioGPT-Large-PubMedQA**: Generates an initial answer.
3. **Mini-LADDER Approach**:
- **Sub-Question Decomposition**: Generates sub-questions from the main query.
- **Self-Critique & Refinement**: Uses a second pass to critique and refine the answer.
4. **Interactive Knowledge Graph**: Displays a PyVis graph of the top documents and key terms.
## Setup Instructions
1. **Install Dependencies**
Create a virtual environment (optional) and install the required packages:
```bash
pip install -r requirements.txt
Set Environment Variables
Set your PubMed API key:
bash
Copy
export PUBMED_API_KEY=<YOUR_NCBI_API_KEY>
Run the App
Launch the Streamlit app:
bash
Copy
streamlit run app.py
Access the App
Open your browser at http://localhost:8501.
Project Structure
Copy
.
β”œβ”€β”€ app.py
β”œβ”€β”€ backend.py
β”œβ”€β”€ mini_ladder.py
β”œβ”€β”€ retrieval.py
β”œβ”€β”€ visualization.py
β”œβ”€β”€ README.md
└── requirements.txt
About the Mini-LADDER Approach
Inspired by Tufa Labs’ LADDER (Learning through Autonomous Difficulty-Driven Example Recursion), this demo shows how a model might:
Decompose a query into simpler sub-questions.
Generate an initial answer using retrieval-augmented generation.
Self-critique and refine the answer based on detected gaps.
Ultimately, this approach hints at how autonomous, recursive learning could be implemented.
Enjoy exploring potential extensions into code generation, theorem proving, or other domains!
yaml
Copy
---
## File: `requirements.txt`
```txt
streamlit
pyvis
chromadb
transformers
sentence-transformers
torch
requests