Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,13 +1,142 @@
|
|
| 1 |
---
|
| 2 |
title: OncoAgent
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
python_version: '3.13'
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: OncoAgent
|
| 3 |
+
emoji: π§¬
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 5.31.0
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
license: apache-2.0
|
| 11 |
+
short_description: Multi-Agent Oncology Triage powered by AMD MI300X
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# 𧬠OncoAgent β Multi-Agent Oncology Triage System
|
| 15 |
+
|
| 16 |
+

|
| 17 |
+

|
| 18 |
+

|
| 19 |
+

|
| 20 |
+

|
| 21 |
+
|
| 22 |
+
> **AMD Developer Hackathon 2026** Β· Powered by AMD Instinctβ’ MI300X Β· ROCm 7.2
|
| 23 |
+
|
| 24 |
+
## π 100% Open-Source: Democratizing Oncology
|
| 25 |
+
OncoAgent is proudly 100% open-source. We believe that life-saving clinical intelligence should not be locked behind proprietary APIs. Our solution is designed to:
|
| 26 |
+
- **Guarantee Patient Privacy:** Run locally on AMD MI300X hardware or private clouds, ensuring zero patient data leaves the hospital.
|
| 27 |
+
- **Foster Global Contribution:** Allow medical communities worldwide to easily audit, modify, and contribute to the RAG knowledge base.
|
| 28 |
+
|
| 29 |
+
OncoAgent is a state-of-the-art multi-agent clinical triage system designed to combat **unstructured data blindness** in primary care oncology. It leverages a tier-adaptive architecture featuring **Qwen 3.5-9B** (Speed Triage) and **Qwen 3.6-27B** (Deep Reasoning) models. Orchestrated via a sophisticated LangGraph state machine, it provides evidence-based oncological reasoning strictly grounded in NCCN/ESMO clinical guidelines, with built-in human-in-the-loop (HITL) safety gates and a Reflexion-based critic loop.
|
| 30 |
+
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
## ποΈ Architecture
|
| 34 |
+
|
| 35 |
+
```
|
| 36 |
+
ββββββββββ βββββββββββ βββββββββββ ββββββββββββββ ββββββββββββββ βββββββββββ
|
| 37 |
+
β Router ββββΆβIngestionββββΆβCorrectiveββββΆβ Specialist βββββββ Critic β β Formatterβ
|
| 38 |
+
β(Triage)β β (PHI) β β RAG β β (Qwen 9B/ β β(Reflexion β β(Output) β
|
| 39 |
+
ββββββββββ βββββββββββ βββββββββββ β 27B) ββββββΆβ Validation)β βββββββββββ
|
| 40 |
+
β β β ββββββββββββββ ββββββββββββββ β²
|
| 41 |
+
β β β β β β
|
| 42 |
+
βΌ βΌ βΌ βΌ βΌ β
|
| 43 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββββββββββββββ
|
| 44 |
+
β Fallback Node β β HITL Gate β
|
| 45 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β(Acuity Chk)β
|
| 46 |
+
ββββββββββββββ
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
**Key Components:**
|
| 50 |
+
|
| 51 |
+
| Module | Description |
|
| 52 |
+
|--------|-------------|
|
| 53 |
+
| `data_prep/` | Dataset builder: PMC-Patients/OncoCoT β Strict JSONL (Llama 3 chat template) |
|
| 54 |
+
| `rag_engine/` | The "Brain": PyMuPDF extraction, Adaptive Semantic Chunking of NCCN/ESMO PDFs, & ChromaDB + PubMedBERT vectorization. |
|
| 55 |
+
| `agents/` | The "Reasoning": LangGraph multi-agent orchestration (Router β Corrective RAG β Specialist β Critic β HITL Gate). |
|
| 56 |
+
| `ui/` | The "Face": Gradio 6 UI with Glassmorphism for clinical note input, real-time source citations, and reasoning output. |
|
| 57 |
+
|
| 58 |
+
---
|
| 59 |
+
|
| 60 |
+
## π§ Dual-Tier Model Strategy (Qwen)
|
| 61 |
+
|
| 62 |
+
To maximize the compute capabilities of the **AMD MI300X**, OncoAgent implements a dynamic **Dual-Tier** routing strategy using the Qwen model family. **Both tiers have been fine-tuned on +200,000 real-world oncological cases covering all major cancer types** (derived from PMC-Patients and OncoCoT datasets) to ensure hyper-specialized medical reasoning:
|
| 63 |
+
|
| 64 |
+
- **Tier 1: Qwen 3.5-9B (Speed Triage):** A lightweight, extremely fast model used by the `Router` to assess initial complexity, perform simple triage, and handle low-risk queries.
|
| 65 |
+
- **Tier 2: Qwen 3.6-27B (Deep Reasoning):** The heavy-lifter. Activated for high-complexity clinical cases (e.g., metastasis, multi-mutations). It performs deep reasoning and entailment checks, avoiding confirmation bias through rigorous Reflexion loops.
|
| 66 |
+
|
| 67 |
+
---
|
| 68 |
+
|
| 69 |
+
## β‘ Hardware Target
|
| 70 |
+
|
| 71 |
+
- **GPU:** AMD Instinctβ’ MI300X (192GB HBM3)
|
| 72 |
+
- **Software Stack:** ROCm 7.2.x, PyTorch (HIP), vLLM with PagedAttention
|
| 73 |
+
- **Models:** `Qwen/Qwen3.5-9B` (Speed Triage) & `Qwen/Qwen3.6-27B-Instruct` (Deep Reasoning)
|
| 74 |
+
- **Precision:** QLoRA 4-bit NormalFloat4 via `bitsandbytes` (ROCm compatible)
|
| 75 |
+
|
| 76 |
+
---
|
| 77 |
+
|
| 78 |
+
## π Quick Start
|
| 79 |
+
|
| 80 |
+
```bash
|
| 81 |
+
# 1. Clone and setup
|
| 82 |
+
git clone <repo-url>
|
| 83 |
+
cd OncoAgent
|
| 84 |
+
|
| 85 |
+
# 2. Install dependencies
|
| 86 |
+
python -m venv .venv
|
| 87 |
+
source .venv/bin/activate
|
| 88 |
+
pip install -r requirements.txt
|
| 89 |
+
|
| 90 |
+
# 3. Start Inference Server (vLLM on Docker)
|
| 91 |
+
# This spins up the Qwen models optimized for AMD MI300X via ROCm PagedAttention
|
| 92 |
+
docker run --device /dev/kfd --device /dev/dri -p 8000:8000 rocm/vllm:latest \
|
| 93 |
+
--model Qwen/Qwen3.6-27B-Instruct --tensor-parallel-size 1
|
| 94 |
+
|
| 95 |
+
# 4. Configure environment & Run UI
|
| 96 |
+
cp .env.example .env
|
| 97 |
+
# Set VLLM_API_BASE=http://localhost:8000/v1 in .env
|
| 98 |
+
python -m ui.app
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
---
|
| 102 |
+
|
| 103 |
+
## π Project Structure
|
| 104 |
+
|
| 105 |
+
```
|
| 106 |
+
βββ docs/ # Documentation & research
|
| 107 |
+
β βββ research/ # Deep Research analysis documents
|
| 108 |
+
β βββ ADR/ # Architectural Decision Records
|
| 109 |
+
β βββ oncoagent_master_directive.md
|
| 110 |
+
β βββ antigravity_rules.md
|
| 111 |
+
βββ data_prep/ # Dataset preparation (Fase 0)
|
| 112 |
+
βββ rag_engine/ # RAG ingestion & retrieval (Fase 0-3)
|
| 113 |
+
βββ agents/ # LangGraph orchestration (Fase 3)
|
| 114 |
+
βββ ui/ # Gradio frontend (Fase 4)
|
| 115 |
+
βββ tests/ # Unit & integration tests
|
| 116 |
+
βββ scripts/ # Utility scripts
|
| 117 |
+
βββ logs/ # Paper log & social media log
|
| 118 |
+
βββ requirements.txt # Pinned dependencies
|
| 119 |
+
βββ Dockerfile # HF Spaces deployment
|
| 120 |
+
```
|
| 121 |
+
|
| 122 |
+
---
|
| 123 |
+
|
| 124 |
+
## π©Ί Safety Guarantees
|
| 125 |
+
|
| 126 |
+
- **Reflexion-based Critic Loop:** A dedicated safety node audits the Specialist's output against the RAG context (entailment verification). It forces the Specialist to regenerate its output if it detects ungrounded claims or invented dosages.
|
| 127 |
+
- **Human-In-The-Loop (HITL) Gate:** An acuity-based checkpoint that stops the pipeline for human clinician approval on high-risk cases (e.g., Stage IV + complex mutations).
|
| 128 |
+
- **Corrective RAG:** The system grades retrieved context relevance. If insufficient evidence is found, it safely falls back instead of guessing.
|
| 129 |
+
- **Zero-PHI:** Regex-based PII redaction before any processing
|
| 130 |
+
- **Reproducibility:** Fixed seeds (`torch.manual_seed(42)`) across all ML scripts
|
| 131 |
+
|
| 132 |
+
---
|
| 133 |
+
|
| 134 |
+
## π License
|
| 135 |
+
|
| 136 |
+
This project was built for the AMD Developer Hackathon 2026.
|
| 137 |
+
|
| 138 |
+
---
|
| 139 |
+
|
| 140 |
+
## π₯ Team
|
| 141 |
+
|
| 142 |
+
Built with β€οΈ and AMD Instinct MI300X.
|