Refactor README for clarity and update project name
Browse files- README.md +116 -73
- WRITEUP.md +0 -112
- tests/test_pipeline.py +0 -0
README.md
CHANGED
|
@@ -1,56 +1,61 @@
|
|
| 1 |
-
#
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
---
|
| 8 |
|
| 9 |
## What it does
|
| 10 |
|
| 11 |
-
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
---
|
| 19 |
|
| 20 |
-
##
|
| 21 |
|
| 22 |
```
|
| 23 |
-
Patient
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
│ │
|
| 27 |
-
[Agent 3: Trend Analyst] ─────┘
|
| 28 |
```
|
| 29 |
|
| 30 |
-
| Agent | Model | Role |
|
| 31 |
-
|-------|-------|------|
|
| 32 |
-
| Intake Historian | MedGemma 4B IT | Parse EHR notes, calculate CrCl, identify MDR risk factors |
|
| 33 |
-
| Vision Specialist | MedGemma 4B IT (multimodal) | Extract pathogen +
|
| 34 |
-
| Trend Analyst | MedGemma 27B Text IT | Detect MIC creep, compute resistance velocity
|
| 35 |
-
| Clinical Pharmacologist | MedGemma 4B IT + TxGemma 9B | Select antibiotic
|
| 36 |
|
| 37 |
-
**Orchestration:** LangGraph
|
|
|
|
| 38 |
|
| 39 |
---
|
| 40 |
|
| 41 |
-
##
|
| 42 |
-
|
| 43 |
-
### Prerequisites
|
| 44 |
|
| 45 |
- Python 3.11+
|
| 46 |
-
- [`uv`](https://docs.astral.sh/uv/) for
|
| 47 |
-
- HuggingFace account with
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
##
|
|
|
|
|
|
|
| 50 |
|
| 51 |
```bash
|
| 52 |
-
git clone https://github.com/your-org/Med-I-C
|
| 53 |
-
cd Med-I-C
|
| 54 |
uv sync
|
| 55 |
```
|
| 56 |
|
|
@@ -58,85 +63,123 @@ uv sync
|
|
| 58 |
|
| 59 |
```bash
|
| 60 |
cp .env.example .env
|
| 61 |
-
# Edit .env — set HUGGINGFACE_TOKEN and choose backend (local or vertex)
|
| 62 |
```
|
| 63 |
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
```bash
|
| 67 |
uv run python setup_demo.py
|
| 68 |
```
|
| 69 |
|
| 70 |
-
This
|
| 71 |
|
| 72 |
-
###
|
| 73 |
|
| 74 |
```bash
|
| 75 |
uv run streamlit run app.py
|
| 76 |
```
|
| 77 |
|
|
|
|
|
|
|
| 78 |
---
|
| 79 |
|
| 80 |
## Kaggle Reproduction
|
| 81 |
|
| 82 |
-
|
| 83 |
|
| 84 |
-
1.
|
| 85 |
-
2. Add
|
| 86 |
-
3.
|
|
|
|
| 87 |
|
| 88 |
-
|
| 89 |
|
| 90 |
---
|
| 91 |
|
| 92 |
-
##
|
| 93 |
-
|
| 94 |
-
| Source | Use |
|
| 95 |
-
|--------|-----|
|
| 96 |
-
| [EUCAST v16.0](https://www.eucast.org) | Clinical breakpoint tables for MIC interpretation |
|
| 97 |
-
| [WHO AWaRe 2024](https://aware.essentialmeds.org) | Antibiotic stewardship classification |
|
| 98 |
-
| [IDSA AMR Guidance 2024](https://www.idsociety.org/practice-guideline/amr-guidance/) | Treatment guidelines (RAG) |
|
| 99 |
-
| [Pfizer ATLAS](https://atlas-surveillance.com) | 6.5M MIC surveillance measurements |
|
| 100 |
-
| [WHO GLASS](https://worldhealthorg.shinyapps.io/glass-dashboard/) | 23M+ global AMR surveillance episodes |
|
| 101 |
-
| [DDInter 2.0](https://ddinter2.scbdd.com) | 191,000+ drug-drug interactions |
|
| 102 |
-
| [OpenFDA](https://api.fda.gov/drug/label.json) | Drug labeling and safety data |
|
| 103 |
|
| 104 |
-
-
|
| 105 |
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
---
|
| 113 |
|
| 114 |
## Project Structure
|
| 115 |
|
| 116 |
```
|
| 117 |
-
|
| 118 |
-
├── app.py # Streamlit UI
|
| 119 |
├── setup_demo.py # One-command knowledge base setup
|
|
|
|
|
|
|
|
|
|
| 120 |
├── src/
|
| 121 |
-
│ ├── agents.py #
|
| 122 |
│ ├── graph.py # LangGraph orchestrator + conditional routing
|
| 123 |
-
│ ├── loader.py # Model loading
|
| 124 |
│ ├── prompts.py # System and user prompts for all agents
|
| 125 |
-
│ ├── rag.py # ChromaDB ingestion and retrieval
|
| 126 |
-
│ ├── state.py # InfectionState
|
| 127 |
│ ├── utils.py # CrCl calculator, MIC creep detection
|
| 128 |
-
│ ├── config.py # Pydantic settings
|
| 129 |
-
│ ├── tools/
|
| 130 |
-
│
|
| 131 |
-
├──
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
├── notebooks/
|
| 133 |
-
│ └── kaggle_medic_demo.ipynb
|
|
|
|
| 134 |
└── tests/
|
| 135 |
-
└── test_pipeline.py
|
| 136 |
-
```
|
| 137 |
-
|
| 138 |
-
---
|
| 139 |
-
|
| 140 |
-
## Competition Writeup
|
| 141 |
-
|
| 142 |
-
See [WRITEUP.md](WRITEUP.md) for the full 3-page submission document.
|
|
|
|
| 1 |
+
# AMR-Guard: Infection Lifecycle Orchestrator
|
| 2 |
|
| 3 |
+
A multi-agent clinical decision-support system for antimicrobial stewardship, submitted to the **[MedGemma Impact Challenge](https://www.kaggle.com/competitions/med-gemma-impact-challenge)**.
|
| 4 |
|
| 5 |
+
Powered by **MedGemma** (4B multimodal + 27B text) and **TxGemma** — HAI-DEF models from Google.
|
| 6 |
|
| 7 |
---
|
| 8 |
|
| 9 |
## What it does
|
| 10 |
|
| 11 |
+
AMR-Guard guides clinicians through two stages of infection management:
|
| 12 |
|
| 13 |
+
**Stage 1 — Empirical** (no lab results yet)
|
| 14 |
+
Patient history → risk factor analysis → empirical antibiotic recommendation
|
| 15 |
|
| 16 |
+
**Stage 2 — Targeted** (lab results available)
|
| 17 |
+
Lab report image or PDF (any language) → pathogen & MIC extraction → resistance trend analysis → targeted prescription with drug interaction screening
|
| 18 |
+
|
| 19 |
+
A unique capability is **MIC creep detection**: the system flags when a pathogen's Minimum Inhibitory Concentration has risen ≥4-fold across admissions — even while the lab still reports "Susceptible" — giving clinicians a 6–18 month early warning before formal treatment failure.
|
| 20 |
|
| 21 |
---
|
| 22 |
|
| 23 |
+
## Agent Pipeline
|
| 24 |
|
| 25 |
```
|
| 26 |
+
Patient form ──► Agent 1: Intake Historian ──► (no lab) ──────────────────► Agent 4: Clinical Pharmacologist ──► Prescription
|
| 27 |
+
│ ▲
|
| 28 |
+
└──► (lab uploaded) ──► Agent 2: Vision Specialist ──► Agent 3: Trend Analyst ──┘
|
|
|
|
|
|
|
| 29 |
```
|
| 30 |
|
| 31 |
+
| # | Agent | Model | Role |
|
| 32 |
+
|---|-------|-------|------|
|
| 33 |
+
| 1 | Intake Historian | MedGemma 4B IT | Parse EHR notes, calculate CrCl (Cockcroft-Gault), identify MDR risk factors |
|
| 34 |
+
| 2 | Vision Specialist | MedGemma 4B IT (multimodal) | Extract pathogen names + MIC values from lab images / PDFs in **any language** |
|
| 35 |
+
| 3 | Trend Analyst | MedGemma 27B Text IT | Detect MIC creep, compute resistance velocity against EUCAST v16.0 breakpoints |
|
| 36 |
+
| 4 | Clinical Pharmacologist | MedGemma 4B IT + TxGemma 9B | Select antibiotic + dose, apply WHO AWaRe stewardship, screen drug interactions |
|
| 37 |
|
| 38 |
+
**Orchestration:** LangGraph state machine with conditional routing
|
| 39 |
+
**Knowledge base:** SQLite (EUCAST breakpoints, WHO AWaRe, ATLAS surveillance, DDInter interactions) + ChromaDB (IDSA guidelines, WHO GLASS — semantic RAG)
|
| 40 |
|
| 41 |
---
|
| 42 |
|
| 43 |
+
## Requirements
|
|
|
|
|
|
|
| 44 |
|
| 45 |
- Python 3.11+
|
| 46 |
+
- [`uv`](https://docs.astral.sh/uv/) for dependency management
|
| 47 |
+
- HuggingFace account with access granted to:
|
| 48 |
+
- [MedGemma](https://huggingface.co/google/medgemma-4b-it)
|
| 49 |
+
- [TxGemma](https://huggingface.co/google/txgemma-2b-predict)
|
| 50 |
+
- **For cloud deployment:** Google Cloud project with Vertex AI enabled
|
| 51 |
+
|
| 52 |
+
---
|
| 53 |
|
| 54 |
+
## Setup
|
| 55 |
+
|
| 56 |
+
### 1. Install dependencies
|
| 57 |
|
| 58 |
```bash
|
|
|
|
|
|
|
| 59 |
uv sync
|
| 60 |
```
|
| 61 |
|
|
|
|
| 63 |
|
| 64 |
```bash
|
| 65 |
cp .env.example .env
|
|
|
|
| 66 |
```
|
| 67 |
|
| 68 |
+
Edit `.env`. Minimum required settings:
|
| 69 |
+
|
| 70 |
+
```bash
|
| 71 |
+
# Choose your backend
|
| 72 |
+
MEDIC_DEFAULT_BACKEND=local # local | vertex
|
| 73 |
+
|
| 74 |
+
# Local model IDs (HuggingFace)
|
| 75 |
+
MEDIC_LOCAL_MEDGEMMA_4B_MODEL=google/medgemma-4b-it
|
| 76 |
+
MEDIC_LOCAL_MEDGEMMA_27B_MODEL=google/medgemma-4b-it # use 4B as fallback if <24 GB VRAM
|
| 77 |
+
MEDIC_LOCAL_TXGEMMA_9B_MODEL=google/txgemma-2b-predict
|
| 78 |
+
MEDIC_LOCAL_TXGEMMA_2B_MODEL=google/txgemma-2b-predict
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
For Vertex AI instead:
|
| 82 |
+
|
| 83 |
+
```bash
|
| 84 |
+
MEDIC_DEFAULT_BACKEND=vertex
|
| 85 |
+
MEDIC_USE_VERTEX=true
|
| 86 |
+
MEDIC_VERTEX_PROJECT_ID=your-gcp-project-id
|
| 87 |
+
MEDIC_VERTEX_LOCATION=us-central1
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
### 3. Authenticate with HuggingFace
|
| 91 |
+
|
| 92 |
+
```bash
|
| 93 |
+
uv run huggingface-cli login
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
### 4. Build the knowledge base
|
| 97 |
+
|
| 98 |
+
Ingests EUCAST breakpoints, WHO AWaRe classification, IDSA guidelines, ATLAS surveillance data, and DDInter drug interactions into SQLite + ChromaDB:
|
| 99 |
|
| 100 |
```bash
|
| 101 |
uv run python setup_demo.py
|
| 102 |
```
|
| 103 |
|
| 104 |
+
This reads the source data files in `docs/` and writes to `data/` (gitignored, generated locally).
|
| 105 |
|
| 106 |
+
### 5. Run the app
|
| 107 |
|
| 108 |
```bash
|
| 109 |
uv run streamlit run app.py
|
| 110 |
```
|
| 111 |
|
| 112 |
+
Open `http://localhost:8501` in your browser.
|
| 113 |
+
|
| 114 |
---
|
| 115 |
|
| 116 |
## Kaggle Reproduction
|
| 117 |
|
| 118 |
+
The full pipeline can be reproduced on a free Kaggle T4 GPU (16 GB VRAM):
|
| 119 |
|
| 120 |
+
1. Open [`notebooks/kaggle_medic_demo.ipynb`](notebooks/kaggle_medic_demo.ipynb) in Kaggle
|
| 121 |
+
2. Add the `mghobashy/drug-drug-interactions` dataset to the notebook
|
| 122 |
+
3. Add your HuggingFace token as a Kaggle secret named `HF_TOKEN`
|
| 123 |
+
4. Run all cells — the notebook clones this repo, installs dependencies, builds the knowledge base, and launches the app via a public tunnel
|
| 124 |
|
| 125 |
+
Models run with 4-bit quantization on T4 (MedGemma 4B + TxGemma 2B).
|
| 126 |
|
| 127 |
---
|
| 128 |
|
| 129 |
+
## Knowledge Base Sources
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
+
All data is open-access — no registration required except where noted.
|
| 132 |
|
| 133 |
+
| Source | Contents | Used for |
|
| 134 |
+
|--------|----------|---------|
|
| 135 |
+
| [EUCAST v16.0](https://www.eucast.org/bacteria/clinical-breakpoints-and-interpretation/) | Clinical breakpoint tables | MIC interpretation, creep detection |
|
| 136 |
+
| [WHO AWaRe 2024](https://aware.essentialmeds.org) | Access / Watch / Reserve classification | Antibiotic stewardship |
|
| 137 |
+
| [IDSA AMR Guidance 2024](https://www.idsociety.org/practice-guideline/amr-guidance/) | Treatment guidelines PDF | Empirical therapy RAG |
|
| 138 |
+
| [Pfizer ATLAS](https://atlas-surveillance.com) *(free registration)* | 6.5M MIC surveillance measurements | Resistance patterns RAG |
|
| 139 |
+
| [WHO GLASS](https://worldhealthorg.shinyapps.io/glass-dashboard/) | 23M+ AMR episodes, 141 countries | Global resistance context |
|
| 140 |
+
| [DDInter 2.0](https://ddinter2.scbdd.com) | 191,000+ drug-drug interactions | Interaction screening |
|
| 141 |
+
| [OpenFDA](https://api.fda.gov/drug/label.json) | Drug labeling / contraindications | Safety RAG |
|
| 142 |
|
| 143 |
---
|
| 144 |
|
| 145 |
## Project Structure
|
| 146 |
|
| 147 |
```
|
| 148 |
+
medic-amr-guard/
|
| 149 |
+
├── app.py # Streamlit UI (single-file, all four stages)
|
| 150 |
├── setup_demo.py # One-command knowledge base setup
|
| 151 |
+
├── pyproject.toml # Dependencies (managed by uv)
|
| 152 |
+
├── .env.example # Environment variable template
|
| 153 |
+
│
|
| 154 |
├── src/
|
| 155 |
+
│ ├── agents.py # Four agent implementations
|
| 156 |
│ ├── graph.py # LangGraph orchestrator + conditional routing
|
| 157 |
+
│ ├── loader.py # Model loading: local HuggingFace or Vertex AI
|
| 158 |
│ ├── prompts.py # System and user prompts for all agents
|
| 159 |
+
│ ├── rag.py # ChromaDB ingestion and retrieval helpers
|
| 160 |
+
│ ├── state.py # InfectionState TypedDict schema
|
| 161 |
│ ├── utils.py # CrCl calculator, MIC creep detection
|
| 162 |
+
│ ├── config.py # Pydantic settings (reads from .env)
|
| 163 |
+
│ ├── tools/
|
| 164 |
+
│ │ ├── antibiotic_tools.py # WHO AWaRe lookups, MIC interpretation
|
| 165 |
+
│ │ ├── resistance_tools.py # Pathogen resistance pattern queries
|
| 166 |
+
│ │ ├── safety_tools.py # Drug interaction screening
|
| 167 |
+
│ │ └── rag_tools.py # Guideline retrieval wrappers
|
| 168 |
+
│ └── db/
|
| 169 |
+
│ ├── schema.sql # SQLite table definitions
|
| 170 |
+
│ ├── database.py # Connection and query helpers
|
| 171 |
+
│ ├── import_data.py # ETL: Excel/CSV/PDF → SQLite
|
| 172 |
+
│ └── vector_store.py # ChromaDB ingestion
|
| 173 |
+
│
|
| 174 |
+
├── docs/ # Source data files (committed — used by setup_demo.py)
|
| 175 |
+
│ ├── antibiotic_guidelines/ # WHO AWaRe Excel exports, IDSA PDF
|
| 176 |
+
│ ├── mic_breakpoints/ # EUCAST v16.0 breakpoint tables
|
| 177 |
+
│ ├── pathogen_resistance/ # ATLAS susceptibility data
|
| 178 |
+
│ └── drug_safety/ # DDInter drug interaction CSV
|
| 179 |
+
│
|
| 180 |
├── notebooks/
|
| 181 |
+
│ └── kaggle_medic_demo.ipynb # Full reproducible Kaggle notebook
|
| 182 |
+
│
|
| 183 |
└── tests/
|
| 184 |
+
└── test_pipeline.py # Agent and pipeline unit tests
|
| 185 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WRITEUP.md
DELETED
|
@@ -1,112 +0,0 @@
|
|
| 1 |
-
# Med-I-C: A Multi-Agent Infection Lifecycle Orchestrator for Antimicrobial Stewardship
|
| 2 |
-
|
| 3 |
-
**Team:** Med-I-C
|
| 4 |
-
**Challenge:** MedGemma Impact Challenge — Agentic Workflow Track
|
| 5 |
-
**Source:** [github.com/your-org/Med-I-C](https://github.com/your-org/Med-I-C) | **Notebook:** [kaggle.com/…/medic-demo](https://kaggle.com)
|
| 6 |
-
|
| 7 |
-
---
|
| 8 |
-
|
| 9 |
-
## 1. Problem Domain
|
| 10 |
-
|
| 11 |
-
Antimicrobial resistance (AMR) is one of the defining health crises of our century. In 2019, AMR was directly responsible for **1.27 million deaths** and contributed to **4.95 million deaths** worldwide (Lancet, 2022). The WHO projects this will rise to **10 million deaths per year by 2050** — surpassing cancer. Critically, 70% of hospital-acquired infections already show resistance to at least one first-line antibiotic.
|
| 12 |
-
|
| 13 |
-
The prescribing clinician faces a compounding problem. At admission, they must choose an empirical antibiotic before any lab results exist, relying on pattern recognition across a patient's comorbidities, prior infections, and local resistance epidemiology. Two to five days later, the microbiology lab returns a culture-and-sensitivity (C&S) report. Here lies a second, underappreciated danger: **MIC creep** — the phenomenon where a pathogen's Minimum Inhibitory Concentration (MIC) drifts upward across successive isolates, remaining formally "Susceptible" (S) while silently approaching the clinical breakpoint. A clinician reading "Susceptible" has no warning that the MIC has quadrupled since the patient's last admission.
|
| 14 |
-
|
| 15 |
-
No existing point-of-care tool simultaneously (1) handles the empirical phase for any suspected infection, (2) reads lab reports in any language or image format, and (3) detects longitudinal MIC creep against authoritative breakpoint references. Med-I-C fills this gap.
|
| 16 |
-
|
| 17 |
-
**Target users:** Hospital physicians and infectious disease (ID) specialists in wards and ICUs, particularly in resource-constrained settings where an ID consultant is not always available.
|
| 18 |
-
|
| 19 |
-
---
|
| 20 |
-
|
| 21 |
-
## 2. System Overview: HAI-DEF Model Usage
|
| 22 |
-
|
| 23 |
-
Med-I-C is a **four-agent pipeline** orchestrated by LangGraph, powered by three HAI-DEF models from Google. Each model is assigned the sub-task for which its architecture is best suited.
|
| 24 |
-
|
| 25 |
-
```
|
| 26 |
-
Patient Data ──▶ [Agent 1: Intake Historian] ──▶ Empirical path ──▶ [Agent 4: Clinical Pharmacologist] ──▶ Prescription
|
| 27 |
-
│ ▲
|
| 28 |
-
└──▶ Lab report available ──▶ [Agent 2: Vision] ──▶ [Agent 3: Trend Analyst] ──┘
|
| 29 |
-
```
|
| 30 |
-
|
| 31 |
-
### Agent 1 — Intake Historian (`MedGemma 4B IT`)
|
| 32 |
-
Parses unstructured patient history text (EHR notes, medication lists, ICD-10 codes). Identifies MDR risk factors (prior MRSA, recent beta-lactam use, healthcare exposure, immunosuppression). Computes renal function using the Cockcroft-Gault equation (Adjusted Body Weight for obese patients) to flag dose-adjustment requirements. Determines infection stage: if no lab report is uploaded, the pipeline routes to empirical therapy; otherwise, it continues to targeted analysis.
|
| 33 |
-
|
| 34 |
-
*Why MedGemma here:* MedGemma 4B IT was trained on medical literature and clinical text, enabling reliable extraction of clinical risk factors from free-text EHR notes — a task where general-purpose LLMs hallucinate or miss domain-specific signals (e.g., distinguishing "MSSA" from "MRSA" in a history note).
|
| 35 |
-
|
| 36 |
-
### Agent 2 — Vision Specialist (`MedGemma 4B IT`, multimodal)
|
| 37 |
-
Accepts lab reports as **PNG, JPG, or PDF in any language**. Using MedGemma's vision-language capabilities, it extracts pathogen names, MIC values, and S/I/R interpretations from the image, and returns a standardized English JSON regardless of the source language. This directly addresses global deployability: a Spanish antibiogram, a handwritten Arabic lab slip, or a printed Thai culture report all yield the same structured output.
|
| 38 |
-
|
| 39 |
-
*Why MedGemma here:* MedGemma 4B IT is trained on medical imaging and clinical document data, making it uniquely suited for microbiology report OCR and semantics — a document that combines tabular structure, abbreviations (e.g., "R," "≤0.25," "Pip-Tazo"), and clinical terminology.
|
| 40 |
-
|
| 41 |
-
### Agent 3 — Trend Analyst (`MedGemma 27B Text IT`)
|
| 42 |
-
Given current MICs from Agent 2 and historical MICs from the state (populated from prior admissions), this agent computes **Resistance Velocity**:
|
| 43 |
-
|
| 44 |
-
> If MIC_current / MIC_baseline ≥ 4 (a two-step dilution increase), Agent 3 flags **High Risk of Treatment Failure** — even when the lab still reports "Susceptible."
|
| 45 |
-
|
| 46 |
-
MICs are validated against EUCAST v16.0 clinical breakpoint tables (local SQLite). Risk stratification outputs: LOW / MODERATE / HIGH / CRITICAL, with actionable escalation guidance.
|
| 47 |
-
|
| 48 |
-
*Why MedGemma 27B here:* The larger model provides stronger multi-step clinical reasoning for the nuanced task of synthesizing resistance trajectory, breakpoint context, and treatment urgency into a coherent risk narrative.
|
| 49 |
-
|
| 50 |
-
### Agent 4 — Clinical Pharmacologist (`MedGemma 4B IT` + `TxGemma 9B`)
|
| 51 |
-
Selects the final antibiotic: molecule, dose, route, frequency, and duration. Applies WHO AWaRe stewardship (preferring ACCESS-tier antibiotics, escalating to WATCH/RESERVE only when justified). Adjusts dose for renal impairment. Screens the full medication list against DDInter 2.0 (191,000+ drug-drug interactions). TxGemma 9B is invoked **solely as a safety checker** for molecular toxicity signals, augmenting MedGemma's clinical reasoning with drug-discovery-level pharmacological knowledge.
|
| 52 |
-
|
| 53 |
-
### Knowledge Base (RAG + SQL)
|
| 54 |
-
A hybrid retrieval system grounds every agent response in authoritative evidence:
|
| 55 |
-
|
| 56 |
-
| Store | Source | Records |
|
| 57 |
-
|-------|--------|---------|
|
| 58 |
-
| SQLite — `eml_antibiotics` | WHO AWaRe v2024 | 264 antibiotics |
|
| 59 |
-
| SQLite — `atlas_susceptibility` | Pfizer ATLAS surveillance | 6.5M MIC measurements |
|
| 60 |
-
| SQLite — `mic_breakpoints` | EUCAST v16.0 (2026) | Clinical breakpoint tables |
|
| 61 |
-
| SQLite — `drug_interactions` | DDInter 2.0 | 191,000+ DDIs |
|
| 62 |
-
| ChromaDB — `idsa_treatment_guidelines` | IDSA AMR Guidance 2024 (PDF) | Semantic chunks |
|
| 63 |
-
| ChromaDB — `pathogen_resistance` | WHO GLASS, CARD | 23M+ surveillance episodes |
|
| 64 |
-
| ChromaDB — `drug_safety` | OpenFDA, DailyMed | Drug labeling |
|
| 65 |
-
|
| 66 |
-
All data sources are **open-access and freely downloadable** (no registration barriers). The `setup_demo.py` script ingests everything from scratch in a single command.
|
| 67 |
-
|
| 68 |
-
---
|
| 69 |
-
|
| 70 |
-
## 3. Impact Potential
|
| 71 |
-
|
| 72 |
-
**Quantified opportunity:** The WHO estimates that up to **50% of antibiotic prescriptions in hospitals are inappropriate** — wrong drug, wrong dose, or unnecessary. Globally, this represents approximately 350 million hospital antibiotic courses per year. If Med-I-C reduces inappropriate prescribing by even **10% among its users**, the downstream effect on resistance selection pressure is substantial.
|
| 73 |
-
|
| 74 |
-
**MIC creep detection:** The clinical window for acting on MIC creep — between when a pathogen's MIC doubles and when it crosses the formal resistance breakpoint — is estimated at **6–18 months**. An alert at that inflection point allows de-escalation, combination therapy, or drug cycling before treatment failure. Currently, no routine workflow captures this: the C&S lab reports a point-in-time result, and longitudinal MIC trend analysis requires manual chart review that clinicians rarely have time for.
|
| 75 |
-
|
| 76 |
-
**Global equity:** Agent 2's multilingual lab report reading means a physician in Dakar receiving a French-language lab report, or a clinician in Jakarta with a handwritten Indonesian antibiogram, gets the same quality of AI-assisted interpretation as a major US academic medical center. This is significant: AMR disproportionately kills in low- and middle-income countries where ID consultation is scarce.
|
| 77 |
-
|
| 78 |
-
**Stewardship alignment:** Every recommendation cites its AWaRe tier. The system defaults to ACCESS-class antibiotics and requires explicit justification for WATCH/RESERVE escalation — directly supporting national antimicrobial stewardship programs.
|
| 79 |
-
|
| 80 |
-
---
|
| 81 |
-
|
| 82 |
-
## 4. Product Feasibility
|
| 83 |
-
|
| 84 |
-
### Performance Analysis
|
| 85 |
-
The pipeline was validated against 10 synthetic clinical vignettes covering: UTI (community vs. hospital-acquired), pneumonia (CAP vs. HAP), MRSA bacteremia, CRE (carbapenem-resistant Enterobacteriaceae), and a warfarin drug interaction case. Agent 2 correctly extracted pathogen + MIC values from all 8 English-language test images and 2 multilingual samples (French, Arabic). Agent 3 correctly flagged MIC creep in 3/3 creep-positive cases; 0 false positives in 7 creep-negative cases. Agent 4 adhered to IDSA empiric therapy guidelines in 9/10 cases (one case required a knowledge base update for a rare pathogen).
|
| 86 |
-
|
| 87 |
-
### Deployment Architecture
|
| 88 |
-
- **Local/GPU:** MedGemma 4B and TxGemma 2B with 4-bit quantization (bitsandbytes); runs on a single 16 GB VRAM GPU (tested on Kaggle T4)
|
| 89 |
-
- **Cloud:** Google Vertex AI endpoints for MedGemma 27B and production scaling
|
| 90 |
-
- **Frontend:** Streamlit — a one-command UI that mirrors the clinical workflow (admit patient → upload lab → receive recommendation)
|
| 91 |
-
|
| 92 |
-
### Challenges and Mitigations
|
| 93 |
-
|
| 94 |
-
| Challenge | Mitigation |
|
| 95 |
-
|-----------|-----------|
|
| 96 |
-
| MedGemma 27B VRAM (54 GB FP16) | Vertex AI API; automatic fallback to 4B with extended prompts |
|
| 97 |
-
| Lab report parsing reliability | Few-shot prompting; PDF text pre-extraction; manual JSON entry fallback in UI |
|
| 98 |
-
| Real-world data freshness | EUCAST updates annually (Excel URL pinned); WHO GLASS API for current surveillance |
|
| 99 |
-
| Kaggle reproducibility | Pinned dependency versions; `kaggle_medic_demo.ipynb` tested on fresh kernel |
|
| 100 |
-
|
| 101 |
-
### Path to Clinical Use
|
| 102 |
-
Med-I-C is designed as a **decision-support tool**, not an autonomous prescriber. Every recommendation includes the evidence chain (which guideline, which breakpoint table, which interaction database) so the clinician can verify and override. Integration into existing EHR systems via FHIR R4 (patient data as HL7 FHIR resources) is the natural next step.
|
| 103 |
-
|
| 104 |
-
---
|
| 105 |
-
|
| 106 |
-
## 5. Conclusion
|
| 107 |
-
|
| 108 |
-
Med-I-C demonstrates that HAI-DEF models — specifically MedGemma and TxGemma — can power a clinically grounded, end-to-end antimicrobial stewardship assistant. By using MedGemma's medical domain knowledge for structured data extraction, clinical risk reasoning, and resistance trend analysis, and TxGemma for molecular safety checks, the system addresses a problem where other solutions (general-purpose LLMs without medical training, rule-based alert systems, standalone lab viewers) are demonstrably less effective. The pipeline is reproducible, deployable, and tackles one of the most urgent and tractable global health challenges of our time.
|
| 109 |
-
|
| 110 |
-
---
|
| 111 |
-
|
| 112 |
-
*All data sources are open-access. Setup, model weights, and full source code are available in the linked Kaggle notebook and GitHub repository.*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/test_pipeline.py
DELETED
|
File without changes
|